【发布时间】:2022-02-23 22:36:59
【问题描述】:
我正在尝试在本地运行 Flask 应用程序并遇到连接到 localhost 被拒绝的问题。我的应用程序目录结构如下所示:
Directory
- index.py
- app.py
auth
-- init.py
Contents of `init.py`
from flask import Flask,redirect
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from werkzeug.serving import run_simple
from index import application as dashApp
@server_auth.route('/dashboard')
@login_required
def dashboard():
return redirect('/dashboard')
app = DispatcherMiddleware(server_auth,
{'/dashboard': dashApp.server})
# Change to port 80 to match the instance for AWS EB Environment
if __name__ == '__main__':
run_simple('0.0.0.0', 80, app, use_reloader=True, use_debugger=True)
我使用gunicorn auth:app 命令启动应用程序。
[2022-02-11 20:57:24 -0800] [2273] [INFO] Starting gunicorn 20.1.0
[2022-02-11 20:57:24 -0800] [2273] [INFO] Listening at: http://127.0.0.1:8000 (2273)
[2022-02-11 20:57:24 -0800] [2273] [INFO] Using worker: sync
[2022-02-11 20:57:24 -0800] [2274] [INFO] Booting worker with pid: 2274
我已经尝试了一些方法来解决问题。
netstat -avn | grep 8000
tcp4 0 0 127.0.0.1.8000 *.* LISTEN 131072 131072 2273 0 0x0100 0x00000006
关闭firewall、flushed dns cache、清除browser cache,如该链接所述:
https://www.hostinger.com/tutorials/localhost-refused-to-connect-error
【问题讨论】:
-
有几个问题可以帮助您:您的问题在哪里?在本地还是在 Elastic Beanstalk 中?您使用的是哪个 SO?
标签: flask dns localhost firewall