0

I am running a flask server on my remote machine on the same network, whose IP is 192.168.1.11. Hence the flask server endpoint for the networks should be 192.168.1.11:5000 where 5000 is the default port chosen by flask.

However, when I hit a request from my local machine (IP: 192.168.1.10) to 192.168.1.11:5000 it doesn't return anything.

However when I run the following on my local machine (IP: 192.168.1.10) ssh -L 4000:127.0.0.1:5000 user@192.168.1.11 and then hit localhost:4000, it works. I understand that this is Local Port Forwarding in ssh.

But when I run jupyter notebook on the remote machine, it runs on the 192.168.1.11:8890. Then when I run 192.168.1.11:8890 from my local machine, it works.

Why does jupyter work and not flask via the default configs? Is it because jupyter does some sort of remote ssh port forwarding. How do I run some code i.e. that is some configs, etc like ssh -R xxxx:xxxx:xxxx xxxx.

canonball
  • 515
  • 7
  • 22

1 Answers1

1

It seems that your flask server listens only on loopback interface.

From docs:

Externally Visible Server

If you run the server you will notice that the server is only accessible from your own computer, not from any other in the network. This is the default because in debugging mode a user of the application can execute arbitrary Python code on your computer.

If you have the debugger disabled or trust the users on your network, you can make the server publicly available simply by adding --host=0.0.0.0 to the command line:

flask run --host=0.0.0.0

This tells your operating system to listen on all public IPs.

Community
  • 1
  • 1
attdona
  • 17,196
  • 7
  • 49
  • 60