Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask web app not responding to external requests on EC2

I've got a very simple Flask application that I'm hosting on an Amazon EC2 node and for whatever reason I can't see it externally. The flask app is here

from flask import Flask

app = Flask(__name__)
app.config['DEBUG'] = False

@app.route('/')
def hello_world():
    return 'Hello World!'

@app.route('/p1')
def p1():
    return "P1!!!"

if __name__ == '__main__':
    app.run(host='0.0.0.0')

When I run the script it looks like the server is running fine, so in my browser (on a different computer) I put the following :5000 (the IP address I pull off of AWS). What's interesting is that it just seems to hang, and eventually produces an error. My guess is that I'm missing some configuration in AWS but I don't know what it is. Any help would be greatly appreciated

EDIT I tried deploying the app on my local machine. And when I try to access it from the browser using localhost:5000, it works. When I replace localhost with my IP address, it fails

like image 751
sedavidw Avatar asked Jul 23 '13 18:07

sedavidw


1 Answers

In your EC2 instance, the security group is what restricting your entry to the website.

  • Go to AWS portal, select your instance
  • Locate the security group and click the name
  • in the inbound rule window, select add rule
  • Not a recommended security practice but to get it running, select All TCP
  • add '0.0.0.0' in the source

your website will be running

like image 155
Shubhra Jayant Deshpande Avatar answered Oct 21 '22 18:10

Shubhra Jayant Deshpande