A few days ago, I faced one of those annoying local development issues that waste hours and make you question your sanity.
I started my local server like I always do:
http://127.0.0.1:8000
And suddenly…
Failed to listen on 127.0.0.1:8000
An attempt was made to access a socket in a way forbidden by its access permissions
I tried ports 8001, 8002, 8003… all the way to 8010.
Same error. Every. Single. Time.
If this sounds familiar, this post is for you.
The Confusing Part
The first thing any developer does is check if the port is already in use:
netstat -ano | findstr :8000
👉 Nothing. Empty.
So the port is free… right?
Wrong.
This is where Windows tricks you.
The Real Problem (The Part No One Tells You)
On Windows, some ports are reserved by the OS itself.
This usually happens because of:
- Hyper-V
- WSL2
- Docker Desktop
- Windows NAT (WinNAT)
- VPN software
Even if no app is using the port, Windows blocks it internally.
That’s why:
-
netstatshows nothing - Your app still fails to start
- You lose time debugging the wrong thing
How I Found the Truth
Run this command as Administrator:
netsh int ipv4 show excludedportrange protocol=tcp
On my machine, I saw this:
Start Port End Port
7943 8042
Boom.
Port 8000 is inside that range.
That means:
- Windows owns the port
- Your app is not allowed to bind to it
- No process will show up in
netstat
Why This Error Is So Frustrating
- The error message is unclear
- Nothing shows in port checks
- Reinstalling frameworks won’t help
- Killing processes won’t help
I wasted time restarting apps when the problem was the OS itself.
The Fixes (Pick What Fits You)
Option 1: Use a Different Port (Fastest & Safest)
If you just want to move on:
8080
3000
5000
9000
Example (Django):
python manage.py runserver 127.0.0.1:8080
This works without admin access.
Option 2: Disable Hyper-V (Best for Dev Machines)
If you don’t need Hyper-V:
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
Restart your PC
This permanently frees ports like 8000.
Option 3: Shutdown WSL (Temporary)
wsl --shutdown
Good if you only need a quick fix.
Option 4: Restart WinNAT
net stop winnat
net start winnat
⚠️ Requires Administrator access
⚠️ May be temporary
What NOT to Do
❌ Don’t reinstall Python / Node / Django
❌ Don’t keep killing random processes
❌ Don’t fight the firewall first
❌ Don’t assume netstat tells the full story
This is not your app’s fault.
If this post saved you time, feel free to share it with another developer who’s stuck staring at port 8000 right now 😄
Happy coding! 🚀
Top comments (0)