2017-08-03 50 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 

希望能帮助你!