2013-10-10 25 views
1

我有公網IP的服務器上啓動一個新的Django應用程序,然後使用命令來運行它:
爲什麼通過IP訪問是好的,但域失敗?

python manage.py runserver publicip:port 

後來我發現,當我與http://publicip:port訪問它,它工作正常。 但是當我使用該域名(其中被解析到這個IP),它失敗了, 並給出了打擊錯誤:(https://dpaste.de/FIrk

0 errors found 
October 10, 2013 - 10:31:13 
Django version 1.5.1, using settings 'testsite.settings' 
Development server is running at http://*.*.*.*:8709/ 
Quit the server with CONTROL-C. 

Traceback (most recent call last): 
    File "/usr/lib/python2.7/wsgiref/handlers.py", line 86, in run 
    self.finish_response() 
    File "/usr/lib/python2.7/wsgiref/handlers.py", line 127, in finish_response 
    self.write(data) 
    File "/usr/lib/python2.7/wsgiref/handlers.py", line 210, in write 
    self.send_headers() 
    File "/usr/lib/python2.7/wsgiref/handlers.py", line 268, in send_headers 
    self.send_preamble() 
    File "/usr/lib/python2.7/wsgiref/handlers.py", line 189, in send_preamble 
    self._write('HTTP/%s %s\r\n' % (self.http_version,self.status)) 
    File "/usr/lib/python2.7/wsgiref/handlers.py", line 389, in _write 
    self.stdout.write(data) 
    File "/usr/lib/python2.7/socket.py", line 324, in write 
    self.flush() 
    File "/usr/lib/python2.7/socket.py", line 303, in flush 
    self._sock.sendall(view[write_offset:write_offset+buffer_size]) 
    error: [Errno 104] Connection reset by peer 
---------------------------------------- 
Exception happened during processing of request from ('58.33.144.118', 53268) 
Traceback (most recent call last): 
    File "/usr/lib/python2.7/SocketServer.py", line 582, in process_request_thread 
    self.finish_request(request, client_address) 
    File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request 
    self.RequestHandlerClass(request, client_address, self) 
    File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line  150, in __init__ 
    super(WSGIRequestHandler, self).__init__(*args, **kwargs) 
    File "/usr/lib/python2.7/SocketServer.py", line 640, in __init__ 
    self.finish() 
    File "/usr/lib/python2.7/SocketServer.py", line 693, in finish 
    self.wfile.flush() 
    File "/usr/lib/python2.7/socket.py", line 303, in flush 
    self._sock.sendall(view[write_offset:write_offset+buffer_size]) 
error: [Errno 32] Broken pipe 
---------------------------------------- 

任何人都可以給一些建議,找出爲什麼訪問,THX很多。

回答

0

它已經很長時間了,但是我認爲我應該爲有同樣問題的其他人寫下這些內容。

這是因爲中國的域名不是北安(備案),ISP拒絕了該服務器的訪問。

4

運行runserver與域名,而不是IP:

python manage.py foobar.com:8000 

請記住,你most definitely shouldn't use runserver in production

請勿使用此服務器在生產環境。它沒有經過安全審計或性能測試。 (這就是它要留下來的原因,我們在做Web框架,而不是Web服務器,所以改進這個服務器來處理生產環境超出了Django的範圍。)

+0

運行帶域的服務器再次失敗。這只是一個測試,我的製作環境使用nginx/uwsgi,但有同樣的問題。 :( –

+0

還有什麼建議? –

相關問題