2017-08-03 79 views
0

我正在按照Django文檔的第一個教程來運行我的開發服務器,但在嘗試訪問http://127.0.0.1:8000服務器的時候,它無法連接。瀏覽器只是說它無法連接到服務器。這是輸出控制檯當我把命令python manage.py runserver我的Django開發服務器不工作

System check identified no issues (0 silenced). 
August 03, 2017 - 14:31:04 
Django version 1.11.4, using settings 'mysite.settings' 
Starting development server at http://127.0.0.1:8000/ 
Quit the server with CTRL-BREAK. 
Unhandled exception in thread started by <function check_errors.<locals>.wrapper 
at 0x0000000003E14730> 
Traceback (most recent call last): 
    File "C:\Program Files\Python36\lib\site-packages\django\utils\autoreload.py", 
line 228, in wrapper 
    fn(*args, **kwargs) 
    File "C:\Program Files\Python36\lib\site-packages\django\core\management\comma 
nds\runserver.py", line 149, in inner_run 
    ipv6=self.use_ipv6, threading=threading, server_cls=self.server_cls) 
    File "C:\Program Files\Python36\lib\site-packages\django\core\servers\basehttp 
.py", line 164, in run 
    httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6) 
    File "C:\Program Files\Python36\lib\site-packages\django\core\servers\basehttp 
.py", line 74, in __init__ 
    super(WSGIServer, self).__init__(*args, **kwargs) 
    File "C:\Program Files\Python36\lib\socketserver.py", line 453, in __init__ 
    self.server_bind() 
    File "C:\Program Files\Python36\lib\wsgiref\simple_server.py", line 50, in ser 
ver_bind 
    HTTPServer.server_bind(self) 
    File "C:\Program Files\Python36\lib\http\server.py", line 138, in server_bind 
    self.server_name = socket.getfqdn(host) 
    File "C:\Program Files\Python36\lib\socket.py", line 673, in getfqdn 
    hostname, aliases, ipaddrs = gethostbyaddr(name) 
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in position 3: invalid 
continuation byte 

我使用python 3.6.1和Django的1.11.4,在Windows 7

編輯:我忘了提的是,我」 m使用啓動項目(使用命令django-admin startproject mysite生成)而不進行任何編輯。

+0

你應該確保你只使用文本編輯器來編輯你的文件。 –

+0

我還沒有編輯過任何東西。我正在使用啓動項目。我編輯了澄清這個問題的問題。當您打開http:// localhost:8000時,會發生這種情況: – Koert

+0

? –

回答

1

您的主機名必須有一些奇怪的字符,請嘗試更改它。或者你可以嘗試強制Django使用你想要的主機和端口:

python manange.py runserver 127.0.0.1:8000 

希望能幫助你!