简体   繁体   English

部署 Flask 应用程序时,AWS ElasticBeanstalk 中出现 502 Bad Gateway 错误

[英]502 Bad Gateway Error in AWS ElasticBeanstalk while deploying Flask Application

I have created a Flask Application and deployed it in AWS ElasticBeanstalk.我创建了一个 Flask 应用程序并将其部署在 AWS ElasticBeanstalk 中。 On accessing the EBS URL, I am getting the 502 Bad Gateway Error.在访问 EBS URL 时,我收到 502 Bad Gateway Error。 nginx/1.16.1 nginx/1.16.1

On checking the error logs i see the following error:在检查错误日志时,我看到以下错误:

[error] 3789#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 119.82.***.***, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "ec2-**-**-***-33.ap-south-1.compute.amazonaws.com"

I checked all the available solutions, but none of them work.我检查了所有可用的解决方案,但没有一个有效。 Please help.请帮忙。

rename app.py to application.py, in app code to application.将 app.py 重命名为 application.py,在应用代码中重命名为应用程序。 It worked for me.它对我有用。

from flask import Flask, render_template

application = Flask(__name__)

@application.route("/")
def index():
    return render_template('index.html')    

if __name__ == "__main__":
    application.run(debug=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM