Why Port 8000 Suddenly Stopped Working on My Local Machine (and How I Fixed It)
Source: Dev.to
A few days ago I ran into a classic local‑development snag: my server could no longer bind to the usual address.
http://127.0.0.1:8000
Instead of starting, it immediately failed with:
Failed to listen on 127.0.0.1:8000
I tried the next few ports (8001‑8010) with the same result. If this sounds familiar, keep reading.
Checking the Port
The first thing most developers do is see whether the port is already in use:
netstat -ano | findstr :8000
The command returned nothing, suggesting the port was free—yet the bind still failed.
Windows Reserved Ports
On Windows, some ports are reserved by the OS itself. Common culprits include:
- Hyper‑V
- WSL 2
- Docker Desktop
- Windows NAT (WinNAT)
- VPN software
Even when no user‑mode process is listening, Windows can block the port internally, which explains why netstat shows nothing while the application cannot start.
To reveal the ranges that Windows has excluded, run the following command as Administrator:
netsh int ipv4 show excludedportrange protocol=tcp
On my machine the output included:
Start Port End Port
7943 8042
Port 8000 falls within that range, meaning the OS owns it and prevents any application from binding to it. No process will appear in netstat.
Why This Error Is So Frustrating
- The error message is vague.
- Port‑checking tools show no conflict.
- Reinstalling frameworks or killing processes doesn’t help.
- The root cause is the operating system, not your code.
Workarounds
Use an Unreserved Port
Pick a port outside the excluded ranges, e.g.:
- 8080
- 3000
- 5000
- 9000
Django example
python manage.py runserver 127.0.0.1:8080
This works without needing administrator privileges.
Disable Hyper‑V (if you don’t need it)
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
After disabling, restart the PC. The port reservation is cleared permanently.
Shut Down WSL 2 (quick fix)
wsl --shutdown
Restart WinNAT
net stop winnat
net start winnat
⚠️ Requires Administrator access.
General Advice
- Do not reinstall Python, Node, Django, or other runtimes; the issue isn’t with them.
netstatalone won’t reveal OS‑reserved ports—usenetshas shown above.
If this post saved you time, feel free to share it with another developer who’s stuck staring at port 8000. Happy coding! 🚀