简体   繁体   English

Flask App拒绝连接

[英]Flask App Refusing Connections

I am running my flask app with the line: app.run(host='0.0.0.0', debug=True, threaded=True, port=5000, passthrough_errors=False) 我正在使用以下行运行我的Flask应用程序:app.run(host ='0.0.0.0',debug = True,threaded = True,port = 5000,passthrough_errors = False)

but when I go to localhost:5000 it get a ERR_CONNECTION_REFUSED error. 但是当我进入localhost:5000时,出现ERR_CONNECTION_REFUSED错误。 Any thoughts on what's happening? 有什么想法吗? Out when runnning is: 运行时间为:

 * Debug mode: on
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 183-524-396

main.py code: main.py代码:

from flask import Flask
from flask_cors import CORS
from test_1.test1 import test1
from test_1.test_files.error_handler import handle_error
# import rollbar

app = Flask(__name__)



@app.route("/")
def hello():
    return "Hello From Error Reporting Test!"

@app.errorhandler(Exception)
def error_handler(error):
    return handle_error(error)

app.register_blueprint(test1, url_prefix='/test1')
cors = CORS(app, resources={r"/test1/*": {"origins": "*"}},
            headers={'Access-Control-Request-Headers', 'Content-Type', 'Access-Control-Allow-Origin'})

if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True, threaded=True, port=5000, passthrough_errors=False)

It was running inside a docker container, I didn't have the port in the docker run command. 它在docker容器中运行,我在docker run命令中没有端口。 Make sure inside the docker run command you have -p 80:80 (replace 80 with the port you want to run on) 确保在docker run命令中具有-p 80:80(将80替换为要在其上运行的端口)

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

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