Localhost Not Working on VPN?

Developer's Fix

SplitTunnel Team·6 min read·Updated January 2026

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

  1. Start your dev server: npm run dev

  2. Confirm it works before VPN connects

  3. Connect VPN

  4. Try accessing localhost

  5. If broken → VPN is interfering

Diagnosing the Problem

bash
# 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 :3000

If 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:

bash
# Instead of
npm run dev

# Use
HOST=0.0.0.0 npm run dev

Fix 3: Route Dev Tools Direct with SplitTunnel

The most reliable fix: route your development tools outside the VPN tunnel.

1

Install SplitTunnel on your Mac

2

Add development apps to "Direct" routing: Terminal, VS Code, your IDE

3

Local development traffic bypasses VPN entirely

Your localhost connections stay local. Work apps stay on VPN.

Framework-Specific Notes

Next.js / React

bash
# .env.local
HOST=127.0.0.1
PORT=3000

Node.js / Express

javascript
app.listen(3000, '127.0.0.1')

Python / Django / Flask

bash
python manage.py runserver 127.0.0.1:8000

Verifying the Fix

After setting up:

  1. Connect your VPN

  2. Start your dev server

  3. Access localhost in browser

  4. Test API calls between services

  5. 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