Priidu Kull
Priidu Kull

Reputation: 107

How to publicly view website that I am hosting on amazon-ec2?

I have started an amazon-ec2 instance with public a DNS of ec2-12-34-567-89.us-west-2.compute.amazonaws.com. There I have set up a security group, where type=HTTP, protocol=TCP, port range=80, source=0.0.0.0/. I log in to the EC2 instance and launch my app:

$ python3 run.py
 * Running on http://0.0.0.0:0/

Then with browser I try to open: http://ec2-12-34-567-89.us-west-2.compute.amazonaws.com and get an "Unable to connect" message.

What am I missing here?

Edit

With port 80, it ends up like this:

$ python3 run.py
 * Running on http://0.0.0.0:80/
Traceback (most recent call last):
  File "run.py", line 5, in <module>
    app.run(host="0.0.0.0", port=80)
  File "/opt/python/3.4.1/lib/python3.4/site-packages/flask/app.py", line 772, in run
    run_simple(host, port, self, **options)
  File "/opt/python/3.4.1/lib/python3.4/site-packages/werkzeug/serving.py", line 710, in run_simple
   inner()
  File "/opt/python/3.4.1/lib/python3.4/site-packages/werkzeug/serving.py", line 692, in inner
    passthrough_errors, ssl_context).serve_forever()
  File "/opt/python/3.4.1/lib/python3.4/site-packages/werkzeug/serving.py", line 486, in make_server
    passthrough_errors, ssl_context)
  File "/opt/python/3.4.1/lib/python3.4/site-packages/werkzeug/serving.py", line 410, in __init__
    HTTPServer.__init__(self, (host, int(port)), handler)
  File "/opt/python/3.4.1/lib/python3.4/socketserver.py", line 429, in __init__
    self.server_bind()
  File "/opt/python/3.4.1/lib/python3.4/http/server.py", line 133, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "/opt/python/3.4.1/lib/python3.4/socketserver.py", line 440, in server_bind
    self.socket.bind(self.server_address)
PermissionError: [Errno 13] Permission denied

Upvotes: 1

Views: 253

Answers (1)

Priidu Kull
Priidu Kull

Reputation: 107

Appearently I needed to run my code as superuser.

$ **sudo** python3 run.py
 * Running on http://0.0.0.0:80/

Upvotes: 1

Related Questions