简体   繁体   中英

Docker on Elastic Beanstalk - connect() failed (111: Connection refused) while connecting to upstream

I am trying to run a simple Sign Up Flask app on AWS Elastic Beanstalk (this app: https://github.com/jay3dec/PythonFlaskMySQLApp---Part-1 ) connected to an external MySQL database, hosted on AWS RDS.

The app runs perfectly locally (even when I connect to the AWS RDS from my local app).

But when I do eb open in the command line, I get:

502 Bad Gateway

nginx/1.8.1

When I did eb create, I received the warning:

WARN    Only one EXPOSE directive is allowed, using the first one: 3306

because in my Dockerfile, I had:

EXPOSE 3306
EXPOSE 5000

For eb logs, I have:

/var/log/nginx/error.log
-------------------------------------
2016/07/17 15:18:06 [warn] 8928#0: duplicate MIME type "text/html" in /etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker-proxy.conf:11
2016/07/17 15:18:06 [warn] 8934#0: duplicate MIME type "text/html" in /etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker-proxy.conf:11
2016/07/17 15:20:54 [error] 8937#0: *33 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.6.93, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://172.17.0.2:3306/favicon.ico", host: "flasksecgroup-dev.us-east-1.elasticbeanstalk.com", referrer: "http://flasksecgroup-dev.us-east-1.elasticbeanstalk.com/"

My Dockerfile is:

FROM ubuntu:latest

RUN apt-get update -y
RUN apt-get install -y python-pip libmysqlclient-dev python-dev build-    essential
 COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt

# Expose
EXPOSE 3306
EXPOSE 5000

ENTRYPOINT ["python"]
CMD ["app.py"]

This is a port and security firewall issue. Open port 3306 and 5000 to world in your security group. It will work without any error.

如果您可以将Dockerfile添加到存储库中,我可以对其进行检查

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM