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
질문됨 4년 전2699회 조회
2개 답변
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
답변함 4년 전
  • 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
답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠