将flask app发送到Elastic Beanstalk时连接被拒绝

2024-05-13 04:04:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在amazon elastic beanstalk上部署我的flask应用程序。无论何时部署,我都会收到以下错误

2020/06/08 17:03:46 [error] 4311#0: *217 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.81.233, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.31.89.203"

我已经附上下面的标准输出和错误日志

/var/log/web.stdout.log
----------------------------------------
Jun  8 16:50:15 ip-172-31-89-203 web: * Serving Flask app "application" (lazy loading)
Jun  8 16:50:15 ip-172-31-89-203 web: * Environment: production
Jun  8 16:50:15 ip-172-31-89-203 web: WARNING: This is a development server. Do not use it in a production deployment.
Jun  8 16:50:15 ip-172-31-89-203 web: Use a production WSGI server instead.
Jun  8 16:50:15 ip-172-31-89-203 web: * Debug mode: on
Jun  8 16:50:15 ip-172-31-89-203 web: * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

这是我的应用程序的启动命令

    application.run(debug=True, use_reloader=False, host='0.0.0.0',port=5000)

该应用程序在本地运行良好,但部署到EB时运行不正常。问题是什么,如何解决

谢谢大家!


Tags: toiplogweb应用程序httphostserver
1条回答
网友
1楼 · 发布于 2024-05-13 04:04:28

application.py中删除主机和端口:

application.run(debug=True, use_reloader=False)

自动地,Flask应用程序在您的Elastic Beanstalk EC2实例中以127.0.0.1:5000提供,然后通过NGINX暴露在外部

相关问题 更多 >