0

TL;DR http.server works with port forwarding over ssh, but flask does not.

I'm having problems with flask and port forwarding. I'm using putty to forward port 5000 to a windows client via ssh. When I use python3 -m http.server 5000, I can access the on the windows client by going to http://localhost:5000. When I use flask, I can access it locally but not remotely from the windows client.

app.py

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return 'Web App with Python Flask!'

Running flask flask --app app run

The error I'm getting is ERR_CONNECTION_RESET

There is another stackoverflow question Configure Flask dev server to be visible across the network that is similar but does not address the issue at hand. I don't have a remote connection here since I'm tunneling in over ssh. As far as flask is concerned, this connection is coming in locally. Additionally, using the excepted answer of flask run --host=0.0.0.0 still does not work in my case.

J'e
  • 3,014
  • 4
  • 31
  • 55
  • always put FULL error message (starting at word "Traceback") in question (not in comments) as text (not screenshot, not link to external portal). There are other useful information in the full error/traceback. – furas Sep 01 '22 at 00:50
  • maybe flask runs on different port? ie. 8080. OR maybe flask doesn't work at this moment when you try to use tunelling. – furas Sep 01 '22 at 00:52
  • @furas that is the full error message. While the tunnel is active, I can still access it on port 5000 – J'e Sep 01 '22 at 12:03
  • 1
    I don't use Windows so I can't test it. But `flask` works corectly when I use forwarding `ssh -L 5000:localhost:5000` on Linux – furas Sep 01 '22 at 12:51
  • @furas using a ssh tunnel in wsl works but putty does not. – J'e Sep 01 '22 at 13:21

0 Answers0