部署到 AWS 后,我收到 502 bad gateway 错误

After deployment to AWS I get 502 bad gateway error

我使用 gitlab ci/cd 成功地将 nodejs 应用程序部署到 aws elastic beanstalk。但是,当我尝试访问 aws 环境的 link 时,出现 502 bad gateway 错误。我下载了日志文件,下面是我得到的最后日志。

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"

这种情况出了什么问题,如何解决?

更新

这是我使用的ED平台

Node.js 16 running on 64bit Amazon Linux 2

我现在正在使用 HTTP。

Node.js 默认使用端口 3000,但是 EB uses 8080:

By default, Elastic Beanstalk configures the proxy to forward requests to your application on port 8080.

您的错误表明您的应用程序未使用端口 8080,这可以解释为什么 EB 无法连接。