111: Connection refused

0

I'm setting up an Elastic Beanstalk setup to run a Django application. However, when trying to load the application in the web browser, a 502 Bad Gateway error appears. Checking the Elastic Beanstalk logs shows the following error:

connect() failed (111: Connection refused) while connecting to upstream, client: 123.12.12.123, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "foo.eba-1abcdefg.us-east-1.elasticbeanstalk.com"

I've tried setting ALLOWED_HOSTS = ['*'] or ALLOWED_HOSTS = ['foo.eba-1abcdefg.us-east-1.elasticbeanstalk.com'] as well as trying to set the ec2 instance and load balancer security groups to allow incoming traffic to port 8000 to redirect to the elastic beanstalk instance.

But the error persists. What else should I try or look for? Any tips would be much appreciated. Thank you in advance.

Edited by: esfaws on Jun 1, 2020 10:51 PM

esfaws
asked 4 years ago2663 views
2 Answers
0

Hi,

I've been getting the same error when I try to deploy a Dash (plotly) application on AWS Beanstalk. Just to clarify did you execute the pip install gunicorn from the CLI on Beanstalk or did you run it in the virtual environment to store the dependency in the requirements.txt file?

neelm91
answered 4 years ago
  • Hi, were you able to resolve this?

    Thanks in advanced!

0

In case anyone comes across this same problem, I never figured out the true root cause for this application. It was probably some configuration conflict between the Django app and the Elastic Beanstalk deployment.

I ended up starting from scratch with a fresh Django and Elastic Beanstalk CLI install but still ran into the same error. It turned out that the instructions online on Amazon's website are outdated and the newer Amazon Linux 2 does not have gunicorn installed by default. Installing gunicorn was the biggest help in solving the problem.

pip install gunicorn

Also, in case it helps, the following buildspec.yml worked:

version: 0.2

phases:
  install:
    runtime-versions:
      python: 3.8
  pre_build:
    commands:
      - lsb_release -a
      - python -m venv venv
      - . venv/bin/activate
      - pip install --upgrade pip
      - pip install -r mysite/requirements.txt
  post_build:
    commands:
      - echo Build completed on `date`

artifacts:
  files:
    - '**/*'
  base-directory: mysite
esfaws
answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions