Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)
edited by

I have a flask app running on AWS Ubuntu server on port 5000 (flask runs default on port 5000). But when I try to access the server on that port, it never connects.

I added a security group on AWS console as Custom TCP on port 5000 for any IP address 0.0.0.0/0, but still, I cannot access it.

Do I have to restart the server? Or am I missing anything?

Let me know any additional information to provide.


 

1 Answer

0 votes
by (44.4k points)

You need to make sure that your app is listening on an IP which can accept the TCP connections from outside. Use this, so that your app listens on all IPs.

if __name__ == '__main__':

    app.run(host='0.0.0.0', debug = False)

Instead of:

if __name__ == '__main__':

    app.run(host='127.0.0.1', debug = False)

Run this command to see what is the address of the application’s listener:

netstat -an | grep :5000

After the changes, restart your Flask application.

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...