#37022 closed Uncategorized (worksforme)
manage.py runserver fails with "nodename nor servname provided" when run using an rfc6761 hostname
| Reported by: | Chris Rose | Owned by: | |
|---|---|---|---|
| Component: | Utilities | Version: | 5.2 |
| Severity: | Normal | Keywords: | dns runserver |
| Cc: | Chris Rose | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
$ uv run manage.py runserver nomnom.dev.localhost:8441 Watching for file changes with StatReloader 2026-04-03T15:53:16.440737Z [info ] Watching for file changes with StatReloader [django.utils.autoreload] Performing system checks... System check identified no issues (0 silenced). Error: [Errno 8] nodename nor servname provided, or not known
nomnom.dev.localhost doesn't directly resolve in DNS, but it is a valid RFC 6761 special use domain.
I've attached my settings, and because ALLOWED_HOSTS is relevant, here's that value from manage.py shell:
uv run manage.py shell 45 objects imported automatically (use -v 2 for details). Python 3.13.12 (main, Feb 3 2026, 17:53:27) [Clang 17.0.0 (clang-1700.6.3.2)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.conf import settings >>> settings.ALLOWED_HOSTS ['nomnom.dev.localhost'] >>>
Attachments (1)
Change History (6)
by , 4 weeks ago
| Attachment: | settings.py added |
|---|
comment:1 by , 4 weeks ago
comment:2 by , 4 weeks ago
| Description: | modified (diff) |
|---|
Nope. I've been utterly unable to get a stack trace to appear. --traceback did nothing for me either.
comment:3 by , 4 weeks ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
$ python manage.py runserver nomnom.dev.localhost:8441 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). April 04, 2026 - 12:04:50 Django version 5.2.9, using settings 'example.settings' Starting development server at http://nomnom.dev.localhost:8441/ Quit the server with CONTROL-C. WARNING: This is a development server. Do not use it in a production setting. Use a production WSGI or ASGI server instead. For more information on production servers see: https://docs.djangoproject.com/en/5.2/howto/deployment/
This works for me. So I wonder if this is something to do with your setup, perhaps try running ping nomnom.dev.localhost?
comment:4 by , 4 weeks ago
nomnom.dev.localhost does not resolve for me in DNS.
https://datatracker.ietf.org/doc/html/rfc6761#section-6.3 suggests that it's supposed to resolve to loopback.
$ ping nomnom.dev.localhost ping: cannot resolve nomnom.dev.localhost: Unknown host $ dig @ns-59.awsdns-07.com nomnom.dev.localhost $ dig @8.8.8.8 nomnom.dev.localhost $ dog @8.8.8.8 nomnom.dev.localhost Status: NXDomain SOA 23h59m55s A "a.root-servers.net." "nstld.verisign-grs.com." 2026040400 30m00s 15m00s 7d0h00m00s 1d0h00m00s
From what I can tell, it doesn't resolve anywhere, so I'm not sure what my local setup is going to be doing with it.
At a bare minimum I sure would love it if --traceback would show me where this resolution is happening, so that I can attempt to troubleshoot it in more detail, but I can't get a stack trace out of that command.
comment:5 by , 4 weeks ago
It also works on my system (Ubuntu 24.04):
$ ping nomnom.dev.localhost PING nomnom.dev.localhost (::1) 56 data bytes 64 bytes from ip6-localhost (::1): icmp_seq=1 ttl=64 time=0.038 ms $ dig nomnom.dev.localhost ; <<>> DiG 9.18.39-0ubuntu0.24.04.3-Ubuntu <<>> nomnom.dev.localhost ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24028 ;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 65494 ;; QUESTION SECTION: ;nomnom.dev.localhost. IN A ;; ANSWER SECTION: nomnom.dev.localhost. 0 IN A 127.0.0.1 ;; Query time: 0 msec ;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP) ;; WHEN: Sat Apr 04 12:36:37 EDT 2026 ;; MSG SIZE rcvd: 65
To see a traceback, edit the except OSError as e: line in django/core/management/runserver.py. Here's an example if I use an invalid hostname:
Traceback (most recent call last):
File "/usr/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/usr/lib/python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "/home/tim/code/django/django/utils/autoreload.py", line 83, in wrapper
raise e
File "/home/tim/code/django/django/utils/autoreload.py", line 66, in wrapper
fn(*args, **kwargs)
File "/home/tim/code/django/django/core/management/commands/runserver.py", line 144, in inner_run
run(
File "/home/tim/code/django/django/core/servers/basehttp.py", line 265, in run
httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tim/code/django/django/core/servers/basehttp.py", line 78, in __init__
super().__init__(*args, **kwargs)
File "/usr/lib/python3.12/socketserver.py", line 457, in __init__
self.server_bind()
File "/usr/lib/python3.12/wsgiref/simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python3.12/http/server.py", line 136, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.12/socketserver.py", line 473, in server_bind
self.socket.bind(self.server_address)
socket.gaierror: [Errno -2] Name or service not known
The documentation for runserver says, "You can pass in an IP address and port number explicitly."
There's an example with localhost, but I don't know that hostnames are otherwise supported. Have you looked at the code to identify where you believe Django is at fault?