Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
58
rated 0 times [  58] [ 0]  / answers: 1 / hits: 120265  / 2 Years ago, sun, january 30, 2022, 8:58:12

Inside the system, running on virtual machine, I can access the running server at 127.0.0.1:5000.



Although the 'remote' address of the vm is 192.168.56.101 (ping and ssh work fine), I cannot access the server with 192.168.50.101:5000 neither from the virtual machine nor from the local one.



I guess there's something preventing remote connections.



Here's /etc/network/interfaces:



auto eth1
iface eth1 inet static
address 192.168.56.101
netmask 255.255.255.0


ufw is inactive.



How do I fix this problem?


More From » networking

 Answers
6

First of all - make sure that your HTTP server is listening on 192.168.50.101:5000 or everywhere (0.0.0.0:5000) by checking the output of:



netstat -tupln | grep ':5000'


If it isn't, consult Flask's documentation to bind to an address other than localhost.



If it is, allow the traffic using iptables:



iptables -I INPUT -p tcp --dport 5000 -j ACCEPT


From Flask's documentation:




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 debug disabled or trust the users on your network, you can
make the server publicly available simply by changing the call of the
run() method to look like this:



app.run(host='0.0.0.0')


[#33922] Monday, January 31, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ravturtl

Total Points: 335
Total Questions: 132
Total Answers: 110

Location: Tanzania
Member since Wed, Feb 24, 2021
3 Years ago
;