Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
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.3k 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
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...