tutorial icon indicating copy to clipboard operation
tutorial copied to clipboard

"Error: [Errno 11001] getaddrinfo failed" on Windows

Open horeoryang opened this issue 5 years ago • 9 comments

Issue Discription (myvenv) C:\Users\rkfql\djangogirls>python manage.py runserver 0:8000 Performing system checks...

System check identified no issues (0 silenced). July 14, 2020 - 23:15:38 Django version 2.0.13, using settings 'mysite.settings' Starting development server at http://0:8000/ Quit the server with CTRL-BREAK. Error: [Errno 11001] getaddrinfo failed Operating system : WIndows 10 how to solve this error?

horeoryang avatar Jul 14 '20 14:07 horeoryang

I don't know a lot about Windows, but have you tried to listen on 0.0.0.0:8000 instead of 0:8000? If you leave that off entirely, does that work?

ekohl avatar Jul 14 '20 14:07 ekohl

The only place, where I found 0:8000 in our tutorial is here: https://github.com/DjangoGirls/tutorial/blame/master/en/django_start_project/README.md#L184 and it looks, that it was proposed back in 2015: https://github.com/DjangoGirls/tutorial/commit/6e428a4d7e3157ee1cde2f53a9a26dacc63f9045 as a resolution for some unicode problem.

Original commit message doesn't clearly say why we cannot use 0.0.0.0 or even 127.0.0.1.

Did you try 0.0.0.0:8000 or 127.0.0.0:8000 @horeoryang ?

magul avatar Jul 15 '20 11:07 magul

Thank you for your reply. i try your solution that is both of you, but it can't work. i will attach the codes.

(myvenv) C:\Users\이시형\djangogirls>python manage.py runserver 0.0.0.0:8000
Performing system checks...

System check identified no issues (0 silenced).
July 18, 2020 - 13:14:28
Django version 2.0.13, using settings 'mysite.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CTRL-BREAK.
Exception ignored in thread started by: <function check_errors.<locals>.wrapper at 0x000001B2C490BEE0>
Traceback (most recent call last):
  File "C:\Users\이시형\djangogirls\myvenv\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\이시형\djangogirls\myvenv\lib\site-packages\django\core\management\commands\runserver.py", line 141, in inner_run
    run(self.addr, int(self.port), handler,
  File "C:\Users\이시형\djangogirls\myvenv\lib\site-packages\django\core\servers\basehttp.py", line 163, in run
    httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
  File "C:\Users\이시형\djangogirls\myvenv\lib\site-packages\django\core\servers\basehttp.py", line 66, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1264.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 452, in __init__
    self.server_bind()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1264.0_x64__qbz5n2kfra8p0\lib\wsgiref\simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1264.0_x64__qbz5n2kfra8p0\lib\http\server.py", line 140, in server_bind
    self.server_name = socket.getfqdn(host)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1264.0_x64__qbz5n2kfra8p0\lib\socket.py", line 756, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 4: invalid start byte



(myvenv) C:\Users\이시형\djangogirls>python manage.py runserver 127.0.0.0:8000
Performing system checks...

System check identified no issues (0 silenced).
July 18, 2020 - 13:09:04
Django version 2.0.13, using settings 'mysite.settings'
Starting development server at http://127.0.0.0:8000/
Quit the server with CTRL-BREAK.
Error: That IP address can't be assigned to.

horeoryang avatar Jul 18 '20 04:07 horeoryang

It suggests your hostname has unicode in it and Python can't deal with that. https://bugs.python.org/issue26227 is still open. https://stackoverflow.com/questions/25948687/gethostbyaddr-raises-unicodedecodeerror-in-python-3 only has the workaround to rename the system.

ekohl avatar Jul 18 '20 14:07 ekohl

maybe your computer-name is not english. In my case, my computer name was 용준. and got same situation but after I change my computer name to enlish, It work! Try it.

iirbdka avatar Oct 25 '20 04:10 iirbdka

The IP address is still wrong: 127.0.0.0 it must be 127.0.0.1

SteffPeff avatar Dec 29 '20 12:12 SteffPeff

you can try socket.getaddrinfo('localhost', 8080)

9z8 avatar Feb 09 '21 07:02 9z8