0

I'm following the first tutorial of Django docs to run my development server, but in the moment to try to access to the server in http://127.0.0.1:8000 it fails to connect. The browser simply says that it couldn't connect to the server. This is what outputs the console when I put the command python manage.py runserver:

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

I'm using python 3.6.1 and django 1.11.4, on Windows 7.

EDIT: I forget mentioning that i'm using the start project (which generates using the command django-admin startproject mysite) without any edit.

Koert
  • 1
  • 2
  • You should ensure you only use a text editor to edit your files. – Daniel Roseman Aug 03 '17 at 12:55
  • I haven't edited anything. I'm using the start project. I edited the question clarifying this. – Koert Aug 03 '17 at 13:19
  • is this happening when you open http://localhost:8000 ? – alfonso.kim Aug 03 '17 at 13:34
  • It happens when i open 127.0.0.1:8000 in the browser. Localhost:8000 can't stablish connection with the server either. – Koert Aug 03 '17 at 13:38
  • Are you working in a virtualenv? How did you install Django? With `pip install Django`? – nik_m Aug 03 '17 at 13:54
  • No, im not using a virtualenv. And yes, i installed Django with pip like you said. – Koert Aug 03 '17 at 13:59
  • So, everytime you do `django-admin startproject project_name`, from the command line, you get the above error? Nothing in-between? Just the execution of this line and then the error? Besides, **you should you a virtualenv**. – nik_m Aug 03 '17 at 14:20

2 Answers2

1

Your hostname must have some weird characters, try to change it. Or you can try to force Django to use the host and port you want:

 python manange.py runserver 127.0.0.1:8000

Hope that can help you!

Luis Alves
  • 194
  • 2
  • 10
0

you should run the python manage.py runserver command in the respected folder.Like if your manage.py is created inside the myproject folder then you must run the above command inside that folder in the command prompt.Like (venv) C:\Users\sasi\Desktop\Development\myproject\myproject>python manage.py runserver

Hope this will help you

shangavie
  • 1
  • 2