I am trying to run a Flask App locally and running into connection to localhost refused issues. My app directory structure looks something like this:
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)
I launch the App using gunicorn auth:app
command.
[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
I have tried a few things to troubleshoot the issue.
netstat -avn | grep 8000
tcp4 0 0 127.0.0.1.8000 *.* LISTEN 131072 131072 2273 0 0x0100 0x00000006
Turned off the firewall
, flushed dns cache
, clear browser cache
as mentioned in this link:
https://www.hostinger.com/tutorials/localhost-refused-to-connect-error