Firefox was working ok to browse localhost:8000 on a development machine running Django development server. However, it suddenly stops working (perhaps after a nightly update). The Django server is running fine at but when trying to browse it just shows the following page:
Any ideas?
UPDATE: I just checked and the Firefox version shows 78.0.1, Release date July 1, 2020. That's the reason I think Firefox has updated and override the settings that allowed the connection to localhost.
UPDATE 2: I've installed Epiphany browser and it works. So, the problem is definitely on Firefox side.
UPDATE 3: The curl -v localhost:8000 outputs:
* Rebuilt URL to: localhost:8000/
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET / HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.47.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 302 Found
< Date: Wed, 08 Jul 2020 07:03:44 GMT
< Server: WSGIServer/0.1 Python/2.7.12
< Vary: Cookie
< X-Frame-Options: SAMEORIGIN
< Content-Type: text/html; charset=utf-8
< Location: /accounts/login/?next=/
< Content-Length: 0
<
* Closing connection 0UPDATE 4: The curl -6v localhost:8000 outputs:
* Rebuilt URL to: localhost:8000/
* Trying ::1...
* connect to ::1 port 8000 failed: Connection refused
* Failed to connect to localhost port 8000: Connection refused
* Closing connection 0
curl: (7) Failed to connect to localhost port 8000: Connection refused 7 1 Answer
Your app is listening on localhost but as an IPv4 only service, while localhost has both an IPv4 address (127.0.0.1) and an IPv6 address (::1) in your (and most everyone else's) /etc/hosts.
When you try to connect to Firefox resolves localhost to both, and picks one to try and connect to, it does not try them all.
You can solve the issue by explicitly going to 127.0.0.1, or, and since it's 2020 I'd favor this one, by making your app IPv6 aware.
5