2014-09-25 161 views
1

我已經開始了一個亞馬遜ec2實例,公開了一個ec2-12-34-567-89.us-west-2.compute.amazonaws.com的DNS。在那裏我建立了一個安全組,其中type = HTTP,protocol = TCP,端口範圍= 80,源= 0.0.0.0 /。我登錄到EC2實例並啓動我的應用程序:與瀏覽器我嘗試打開如何公開查看我在amazon-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 
+1

那麼,你並沒有運行在80端口上開始。您是使用VPC還是EC2 classic推出您的實例? – alfasin 2014-09-25 06:33:42

+0

試過 $ python3 run.py *在http://0.0.0.0:8001/ 上運行,但沒有成功。 我該如何檢查VPC vs EC2 classic?當我啓動實例時,我以爲我正在啓動一個EC2實例。 – 2014-09-25 06:40:03

+1

8001仍然不是80端口。如果您希望這些其他端口可用,您必須在安全組中聲明它。至於VPC/EC2-classic:當你進入菜單左上角的aws-console時,你將擁有EC2作爲第二名,下面的兩項將是VPC。 – alfasin 2014-09-25 07:02:37

回答

1

Appearently我需要我的代碼運行的超級用戶。

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

是的,你應該使用root運行80端口較低端口 – Nabin 2017-08-22 02:18:29

+0

這裏有一些討論https://stackoverflow.com/questions/25709716/socket-error-errno-13-permission-denied-when-creating-a-fake-email-server – Nabin 2017-08-22 02:20:04

相關問題