我已经开始使用ec2-12-34-567-89.us-west-2.compute.amazonaws.com的DNS开发了一个amazon-ec2实例。我在那里设置了一个安全组,其中type = HTTP,protocol = TCP,port range = 80,source = 0.0.0.0 /。我登录EC2实例并启动我的应用程序:
$ python3 run.py
* Running on http://0.0.0.0:0/
然后使用浏览器我尝试打开:http://ec2-12-34-567-89.us-west-2.compute.amazonaws.com并获得"无法连接"消息。
我在这里缺少什么?
修改
使用端口80,它最终会像这样:
$ 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
答案 0 :(得分:1)
显然我需要以超级用户身份运行我的代码。
$ **sudo** python3 run.py
* Running on http://0.0.0.0:80/