【发布时间】:2021-03-07 23:42:58
【问题描述】:
我是一名编程新手,我的老板希望我在 AWS elastic beanstalk 上部署一个 dash plotly 应用程序。代码部署成功,但显示502 bad gateway 错误。
502 错误网关
nginx/1.18.0
我尝试查看 /var/log/nginx/error.log 并将端口更改为8000,但仍然无效。
这个错误的解决方法是什么?我应该添加 Procfile 吗?我应该在该文件中添加什么?提前非常感谢!
/var/log/nginx/error.log
2020/11/25 05:24:52 [error] 16068#0: *38 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.38.82, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.7.83"
2020/11/25 05:25:01 [error] 16068#0: *40 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.2.244, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.7.83"
2020/11/25 05:25:07 [error] 16068#0: *42 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.38.82, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.7.83"
2020/11/25 05:25:16 [error] 16545#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.2.244, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.7.83"
2020/11/25 05:25:22 [error] 16545#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.38.82, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "dashmonitoring1-env.eba-umwfi3nn.us-east-2.elasticbeanstalk.com"
2020/11/25 05:25:22 [error] 16545#0: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.38.82, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.7.83"
2020/11/25 05:25:22 [error] 16545#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.38.82, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8000/favicon.ico", host: "dashmonitoring1-env.eba-umwfi3nn.us-east-2.elasticbeanstalk.com", referrer: "http://dashmonitoring1-env.eba-umwfi3nn.us-east-2.elasticbeanstalk.com/"
2020/11/25 05:25:31 [error] 16545#0: *8 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.2.244, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.7.83"
2020/11/25 05:25:37 [error] 16545#0: *10 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.38.82, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.7.83"
2020/11/25 05:25:46 [error] 16545#0: *12 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.2.244, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.7.83"
2020/11/25 05:25:52 [error] 16545#0: *14 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.38.82, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.7.83"
2020/11/25 05:26:01 [error] 16545#0: *16 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.2.244, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.7.83"
2020/11/25 05:26:07 [error] 16545#0: *18 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.38.82, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.7.83"
【问题讨论】:
-
"端口改成8000" - 端口改在哪里?
-
嗨@Marcin - 感谢您的回复!我更改了 application.py 中的端口 [if name == 'main': application.run(debug=True, port=8000)]
-
默认端口不是5000吗?无论如何,如果你 ssh 进入 EB 实例,你能确认它在 localhost 上工作吗?
-
@Marcin 对我来说默认是 8080,但错误日志建议 8000,因此我更改了它。 dash 应用在本地运行良好。
-
如果我给你我最近 100 条来自 Elastic beanstalk 的日志会有用吗?我是手动部署的。
标签: python python-3.x amazon-web-services amazon-elastic-beanstalk plotly-dash