http://localhost
or 127.0.0.1
stopped working after a Windows 11 update:
- Repair
C:\Windows\System32\drivers\etc\hosts
(UTF-8 no BOM; add127.0.0.1 localhost
and::1 localhost
). - Disable system proxy/VPN capture of loopback; clear Automatically detect settings if it injects a PAC.
- Reset Winsock/DNS, verify your app binds to
127.0.0.1
/::1
, and allow it through Windows Defender Firewall.
Quick Diagnostics
# 1) Does loopback resolve? ping localhost ping 127.0.0.1 ping ::1 # 2) Is something listening on the expected port? netstat -ano -p tcp | find ":3000" # or 80/443/5000/8000 as needed # 3) Does name resolution hit your hosts file or DNS? nslookup localhost
Red flags: “Ping request could not find host localhost”, nslookup returns external DNS answers, or your service is bound to an unexpected interface.
Fix 1 — Repair the hosts
File (common post-update break)
- Open Notepad as Administrator → File → Open → browse to
C:\Windows\System32\drivers\etc
→ choose All Files → open hosts. - Ensure it contains exactly:
127.0.0.1 localhost ::1 localhost
- Encoding: Save as UTF-8 (no BOM). Avoid UTF-16/Unicode—Windows networking won’t parse it correctly.
- Make sure the filename is hosts (no
.txt
) and permissions allow Read for SYSTEM/Users.
Fix 2 — Disable System Proxy/VPN Interference
- Settings → Network & Internet → Proxy: Turn off Use a proxy server. If your environment uses a PAC file, verify it doesn’t divert
localhost
/127.0.0.1
. - Corporate VPN: disable force tunnel or add split-tunnel exceptions for
127.0.0.1
,::1
, andlocalhost
. Some VPNs hijack loopback by design. - Browser: disable extensions that “secure” traffic by proxying all requests, including localhost.
Fix 3 — Reset the TCP/IP Stack & DNS
# Run in elevated CMD or PowerShell ipconfig /flushdns netsh winsock reset netsh int ip reset shutdown /r /t 5
Fix 4 — Verify Your Service’s Bindings
After updates, frameworks may switch defaults (e.g., IPv6 ::1
vs IPv4 127.0.0.1
) or only listen on a specific interface.
- Node/Express:
app.listen(3000, "127.0.0.1")
(or::1
). Avoid binding only to a Docker/WSL address. - .NET / Kestrel / IIS Express: Check
applicationhost.config
orlaunchSettings.json
applicationUrl
→ includehttp://localhost:xxxx
. - Python Flask/FastAPI:
app.run(host="127.0.0.1")
. If usinghost="0.0.0.0"
, ensure your firewall allows local connections. - MySQL/Postgres: Confirm
bind-address=127.0.0.1
(MySQL) orlisten_addresses='localhost'
(Postgres).
Fix 5 — Allow Your App Through Windows Defender Firewall
- Open Windows Defender Firewall with Advanced Security.
- Create an Inbound Rule → Program or Port (e.g., 3000/5000/8000/80/443) → Allow → Profile: Domain/Private.
- Scope: leave local/remote as Any (loopback is treated as local). If you tightened scope, explicitly include
127.0.0.1
and::1
.
Fix 6 — WSL2/Docker & Hyper-V: Make Peace with Loopback
- Docker Desktop: enable “Use the WSL 2 based engine”. Map ports:
-p 127.0.0.1:3000:3000
so the host loopback gets the traffic. - WSL2: prefer
localhostForwarding=true
in.wslconfig
. If broken, restart:wsl --shutdown
then relaunch. - Disable Internet Connection Sharing (ICS) if it rewrites bindings on developer NICs.
One-Click (ish) PowerShell Repair
Run as Administrator. This script validates hosts, resets proxy/Winsock, and opens common dev ports on Private networks.
$hosts = "$env:SystemRoot\System32\drivers\etc\hosts" $need = @("127.0.0.1 localhost","::1 localhost") $content = Get-Content -LiteralPath $hosts -ErrorAction SilentlyContinue if (-not $content) { $content = @() } $changed = $false foreach ($l in $need) { if ($content -notcontains $l) { $content += $l; $changed = $true } } if ($changed) { Set-Content -LiteralPath $hosts -Value $content -Encoding utf8 } # Disable system proxy (current user) Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' ProxyEnable 0 -Type DWord # Reset DNS/Winsock/IP ipconfig /flushdns | Out-Null netsh winsock reset | Out-Null netsh int ip reset | Out-Null # Open common dev ports on Private profile $ports = 80,443,3000,5000,8000,8080 foreach ($p in $ports) { if (-not (Get-NetFirewallRule -DisplayName "CYDDB-Dev-$p" -ErrorAction SilentlyContinue)) { New-NetFirewallRule -DisplayName "CYDDB-Dev-$p" -Direction Inbound -Action Allow -Protocol TCP -LocalPort $p -Profile Private | Out-Null } } Write-Host "Loopback repaired. Reboot recommended."
Still Broken? Quick Triage Checklist
- Try
http://127.0.0.1:PORT
andhttp://[::1]:PORT
(IPv4 vs IPv6). - Test in another browser (extensions can proxy/inspect localhost).
- Temporarily disable security suites that inject network filters (they can intercept loopback).
- Roll back the last KB update if this began immediately after Patch Tuesday (Settings → Windows Update → Update history → Uninstall updates).
Developer & Security Essentials (sponsored)
localhost
local.Disclosure: We may earn a commission if you buy via these links. This supports independent research.
Windows 11 update, localhost not working, 127.0.0.1 fix, loopback, hosts file, proxy PAC, VPN split tunneling, Winsock reset, WSL2, Docker Desktop, IIS Express, Kestrel, Node.js, Python Flask, DevOps, enterprise IT.
#Windows11 #Localhost #127001 #Loopback #DevOps #WSL2 #Docker #IISExpress #Kestrel #Networking #Proxy #VPN #Winsock #SysAdmin #Helpdesk #US #EU #UK #Australia #India
Educational guidance for legitimate troubleshooting. Test in a non-production environment before applying to enterprise fleets.
Comments
Post a Comment