Flask App Refusing Connections

我正在运行我的Flask应用程序:
app.run(host=’0.0.0.0′, debug=True, threaded=True, port=5000, passthrough_errors=False)

但是当我转到 localhost:5000 时,它会收到 ERR_CONNECTION_REFUSED 错误。对正在发生的事情有任何想法吗?
运行时输出为:

1
2
3
4
5
 * Debug mode: on
 * Running on http://0.0.0.0: 5000/ (Press CTRL+C to quit )
 * Restarting with stat
 * Debugger is active !
 * Debugger PIN: 183524396

main.py 代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 )



相关讨论

  • 您在此应用程序中有任何端点吗?
  • 请将您的Flask应用程序减少到可以证明问题的最短程序。 (一个”hello world”Flask应用程序可以短至 20 行)。将该应用程序复制粘贴到您的问题中。
  • 我有,但它们是为了抛出错误而编写的。我正在构建一个简单的应用程序来测试错误跟踪器。
  • 我现在收到 ERR_EMPTY_RESPONSE


它在 docker 容器中运行,我在 docker run 命令中没有端口。确保在 docker run 命令中有 -p 80:80 (将 80 替换为要运行的端口)


声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。