简体   繁体   English

AWS beanstalk 上的 Python Flask 给出 502 网关错误

[英]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.

相关问题 AWS使用python flask不断返回502错误的网关错误 - aws keep returning 502 bad gateway error using python flask 部署 Flask 应用程序时,AWS ElasticBeanstalk 中出现 502 Bad Gateway 错误 - 502 Bad Gateway Error in AWS ElasticBeanstalk while deploying Flask Application Nginx / Flask / Python应用程序,Nginx抛出502 Bad Gateway错误 - Nginx/Flask/Python App, Nginx throwing 502 Bad Gateway Error Python 中的 Selenium + Flask/Falcon - 502 错误网关错误 - Selenium + Flask/Falcon in Python - 502 Bad Gateway Error nginx烧瓶aws 502 Bad Gateway - nginx flask aws 502 Bad Gateway 将 Django 应用程序部署到 Elastic Beanstalk AWS 502 错误网关 - Deploying a Django application to Elastic Beanstalk AWS 502 Bad Gateway AWS beantalk + Django:502 错误网关 - ModuleNotFoundError:没有名为“application”的模块 - AWS beanstalk + Django: 502 Bad Gateway - ModuleNotFoundError: No module named 'application' AWS Elastic Beanstalk(Dash plotly 应用程序)- 502 错误网关 - AWS Elastic Beanstalk (Dash plotly app) - 502 Bad Gateway 使用 AWS 放大时出现 502 网关错误,cloudwatch 在随机线路上给出错误? - 502 gateway error when utilizing AWS amplify, cloudwatch gives error on random line? Nginx 502错误网关错误时带有gunicorn的烧瓶 - Flask with gunicorn on nginx 502 bad gateway error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM