Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to web app running on localhost on an Amazon EC2 from another computer

currently I am working on a web app development and I am running my server on an Amazon ec2 instance. I am testing my (web app which uses Flask) by running the server on localhost:5000 as usual. However I don't have access to the gui hence I don't see my app and test it like I would do on a browser. I have a Mac OS X computer so my question is how can I see the localhost of Amazon EC2 from my mac's browser ?

like image 574
cauchy_cat Avatar asked Aug 19 '15 08:08

cauchy_cat


1 Answers

You need to tell the Flask Dev webserver to run on 0.0.0.0 instead of localhost.

You specify this option when calling the .run() function:

app.run(host='0.0.0.0', debug=True, port=5000)

If you then send a request to the Public IP of your EC2 instance on port 5000 you will reach your Flask Dev webserver.

eg: http://EC2_IP:5000/

Hope this helps :)

like image 129
mickzer Avatar answered Nov 14 '22 21:11

mickzer