Nginx 502 Bad Gateway Error on Elastic Beanstalk Node.js Backend

0

I'm encountering a frustrating issue with my Elastic Beanstalk environment running a Node.js backend. Everything was working fine, but suddenly, I started receiving a 502 Bad Gateway error from Nginx. Here’s the relevant log entry:

2024/08/02 15:03:57 [error] 993452#993452: *3773 connect() failed (111: Connection refused) while connecting to upstream, client: 135.125.246.189, server: , request: "GET /.env HTTP/1.1", upstream: "http://127.0.0.1:8080/.env"

Details:

Environment: Elastic Beanstalk for Node.js Port Configuration: The application was running on port 8080 for last 15 days and Suddenly 502 error popped up. Recent Changes: (Include any recent changes you made, if applicable) If any further information is required, I can provide additional details. Please help out!

질문됨 6달 전291회 조회
1개 답변
1
수락된 답변

The error "connect() failed (111: Connection refused) while connecting to upstream" indicates that the application is not responding. The issue is associated with the application itself. It can be because it is using a different port or it can be because the application is not running at all.

To troubleshoot, I would check the file "web.stdout.log" in Bundle logs. Also, you can try to login inside the EC2 instance ( using SSH/SSM ..) and run:

curl http://localhost:<application_port_number>

For example:

curl http://127.0.0.1:8080

if no response received, this means that the application is not running on port 8080. Then, check if it is using a different port. To verify, try running the command: Note: For NodeJS applications, I would recommend checking port 3000 and port 5000.

netstat -ltpn

And, check which port has the nodejs process listening on. If no port found associated with nodejs, then the application is down. You need to examine "web.stdout.log" for application errors.

AWS
지원 엔지니어
답변함 5달 전

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

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

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

관련 콘텐츠