[英]Python Flask on AWS beanstalk gives 502 gateway error
My Pyhon Flask app is set to listen on port 5000 when deployed to AWS beanstalk.当部署到 AWS beanstalk 时,我的 Pyhon Flask 应用程序设置为侦听端口 5000。 The app starts successfully.应用程序成功启动。 But when I try to access it.但是当我尝试访问它时。 It gives 502 gateway error.它给出 502 网关错误。 Then I downloaded full log and check the nginx log, and found out it is actually forwarding request to port 8000. So I changed my app to listen on port 8000 and deployed again.然后我下载了完整的日志并检查了 nginx 日志,发现它实际上是将请求转发到端口 8000。所以我将我的应用程序更改为监听端口 8000 并再次部署。 Now the app failed to start, and in the log it has the error address already in use.现在应用程序无法启动,并且在日志中它的错误地址已在使用中。 Anybody having the same problem?有人有同样的问题吗? Any help would be appreciated.任何帮助,将不胜感激。
OK, finally found out the problem. OK,终于找到问题所在了。 you will have to have if name == " main ": wrap your app.run()如果name == " main " 你必须有:包装你的app.run()
Not working:不工作:
app.run()
Fixed:固定的:
if __name__ == "__main__":
app.run()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.