Issue
I have a google cloud compute engine instance with Ubuntu 16.04 on it. I have a flask app running on port 5000.
I've set up firewall rules to allow ingress traffic for any host (using 0.0.0.0/0 filter) for tcp:5000. I ran the
sudo ufw allow 5000
command on the console.
At this point I was expecting to see the flask app by entering http://external_ip:5000 on my browser. But that is not the case. I get "external_ip refused to connect." error on the browser. What am I doing wrong?
Its working if I run the flask app on port 80 though.
As the allow-internal rule is active in the firewall rules. I thought maybe try accessing from a node under the same project (thus same default network). But no luck.
Solution
I had the same problem. The way to fix is, to add host parameter to Flask app as shown below. By default Flask App is designed to work on localhost only. This has fixed the problem for me
if __name__ == '__main__':
app.run(debug=False, port=8081, host='0.0.0.0')
Answered By - Karthik Sunil
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.