Hello Community,
I am developing a hololens project. I got a server which uses Flask for python. Everytime I try to connect via WWW I get the error, that it failed to connect to xxxxx port 5005: bad access. But I can reach the IP and the get-service via the browser on the same computer.
Does anyone got the same problem and maybe figured out, where it comes from?
Greetings
Hello BoneZer91,
when you are running the server via flask run change it to flask run --host=0.0.0.0 to connect, find the IPV4 address of the server that your script is running on. On the same network, go to http://[IPV4 address]:5000
A reason could also be in firewall refusing incoming connections on port 5000. Try:
sudo ufw allow 5000
Thanks for your answer. But I already went over the ipv4 address. The firewall shouldn’t be a problem, because I can reach the server via browser(even in Visual Studio).
Quick note i found
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’)
or
if name == ‘main’:
app.run(host=‘0.0.0.0’)