Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS elastic Beanstalk / nginx : connect() failed (111: Connection refused

I got this message

connect() failed (111: Connection refused

Here is my log:

-------------------------------------
/var/log/nginx/error.log
-------------------------------------
2018/10/21 06:16:33 [error] 4282#0: *2 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.4.119, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8081/", host: "hackingdeal-env.qnyexn72ga.ap-northeast-2.elasticbeanstalk.com"
2018/10/21 06:16:33 [error] 4282#0: *2 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.4.119, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8081/favicon.ico", host: "hackingdeal-env.qnyexn72ga.ap-northeast-2.elasticbeanstalk.com", referrer: "http://hackingdeal-env.qnyexn72ga.ap-northeast-2.elasticbeanstalk.com/"

I am using nodejs/express Elastic Beanstalk env.

I have one nginx related file in

.ebextensions/nginx/conf.d/proxy.conf

Upper file contains:

client_max_body_size 50M;

Whenever I try to get my webpage I got 502 bad gateway.

What's wrong with my app?

like image 842
leonkong Avatar asked Oct 21 '18 06:10

leonkong


2 Answers

Just recording my incident here just in case it helps someone or my future self. I had a Django application that had SECURE_SSL_REDIRECT set to True. Since I had no load balancers configured to handle HTTPS traffic I was getting a timeout. Setting it to False fixed the issue. Couple of days wasted on that one.

like image 172
MadeOfAir Avatar answered Oct 24 '22 06:10

MadeOfAir


111 connection refused likely means your app isn't running on the server/port combination. Also check that the security group for your app instance (or load balancer) has an inbound rule set to allow traffic from the nginx instance

like image 38
sofcal Avatar answered Oct 24 '22 06:10

sofcal