I successfully deployed the nodejs application to aws elastic beanstalk using gitlab ci/cd. However, when I try to visit the link of the aws environment I get 502 bad gateway error. I downloaded the logs file and below are last logs that I get.
2022/03/20 04:58:57 [error] 723#723: *97 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.0.96, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "172.31.13.104"
2022/03/20 04:59:02 [error] 723#723: *99 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.73.189, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "172.31.13.104"
2022/03/20 04:59:12 [error] 723#723: *101 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.0.96, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "172.31.13.104"
2022/03/20 04:59:17 [error] 723#723: *103 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.73.189, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "172.31.13.104"
2022/03/20 04:59:27 [error] 723#723: *105 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.0.96, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "172.31.13.104"
2022/03/20 04:59:32 [error] 723#723: *107 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.73.189, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "172.31.13.104"
2022/03/20 04:59:42 [error] 723#723: *109 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.0.96, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "172.31.13.104"
What is going wrong in this case and how to solve it?
UPDATE
Here is the ED platform I am using
Node.js 16 running on 64bit Amazon Linux 2
I am using HTTP for now.
CodePudding user response:
Node.js
uses port 3000 by default, but EB uses 8080
:
By default, Elastic Beanstalk configures the proxy to forward requests to your application on port 8080.
Your error indicates that your application does not use port 8080, which would explain why EB fails to connect.