node.jsamazon-web-servicesexpressnginxamazon-elastic-beanstalk

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?


Solution

  • 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