Localhost Not Working on VPN?
Developer's Fix
Key Takeaways
Some VPNs redirect localhost/127.0.0.1 traffic or block local ports
This breaks local development servers, APIs, and databases
Split tunneling ensures localhost always stays local
Why Localhost Breaks on VPN
Localhost (127.0.0.1) should always be local—that's the whole point. But some VPNs intercept all traffic, including localhost.
- •
DNS-based VPNs redirect "localhost" hostname resolution
- •
Full-tunnel VPNs intercept all IP traffic
- •
Port conflicts with VPN services
- •
"Zero trust" corporate VPNs that inspect everything
The result: connection refused, timeouts, or your dev server just won't respond.
Common Symptoms
You'll know VPN is interfering when:
- •
http://localhost:3000 — connection refused
- •
127.0.0.1:8080 — timeout
- •
Local API calls fail from your app
- •
Database connections (localhost:5432) fail
- •
Hot reload stops working
Quick Test
Start your dev server: npm run dev
Confirm it works before VPN connects
Connect VPN
Try accessing localhost
If broken → VPN is interfering
Diagnosing the Problem
# Test basic localhost
curl http://localhost:3000
# Test with IP directly
curl http://127.0.0.1:3000
# Check if port is listening
lsof -i :3000If 127.0.0.1 works but localhost doesn't, you have a DNS redirection issue.
Fix 1: Use 127.0.0.1 Instead of localhost
Sometimes "localhost" gets redirected by VPN DNS, but the IP address stays local. Try http://127.0.0.1:3000 instead of http://localhost:3000.
Fix 2: Bind to 0.0.0.0
Some dev servers only bind to localhost. Try binding to all interfaces:
# Instead of
npm run dev
# Use
HOST=0.0.0.0 npm run devFix 3: Route Dev Tools Direct with SplitTunnel
The most reliable fix: route your development tools outside the VPN tunnel.
Install SplitTunnel on your Mac
Add development apps to "Direct" routing: Terminal, VS Code, your IDE
Local development traffic bypasses VPN entirely
Your localhost connections stay local. Work apps stay on VPN.
Framework-Specific Notes
Next.js / React
# .env.local
HOST=127.0.0.1
PORT=3000Node.js / Express
app.listen(3000, '127.0.0.1')Python / Django / Flask
python manage.py runserver 127.0.0.1:8000Verifying the Fix
After setting up:
Connect your VPN
Start your dev server
Access localhost in browser
Test API calls between services
Confirm hot reload works
Frequently Asked Questions
Get Back to Coding
Route dev tools direct while work apps stay on VPN. Localhost just works.
7-day free trial · Cancel anytime