High severity Updated 2 days ago · 12,403 views

Localhost refused to connect
on port 3000

Your browser returned ERR_CONNECTION_REFUSED while reaching http://localhost:3000. This means the server is either not running, bound to a different interface, or blocked by a firewall.

Error code

browser-console.log
// Chrome DevTools → Console
GET http://localhost:3000/ net::ERR_CONNECTION_REFUSED

// Node.js server log
Error: listen EADDRINUSE: address already in use :::3000
    at Server.setupListenHandle [as _listen2] (node:net:1872:16)
    at listenInCluster (node:net:1920:12)
    at doListen (node:net:2060:7)

Root cause

Chromium returns ERR_CONNECTION_REFUSED when the TCP connection is actively rejected — meaning nothing is listening on the target port, or a firewall refused the handshake. With Node.js, this almost always pairs with EADDRINUSE in the terminal, telling you a previous process is still bound to the port.

Resolution steps

Work through these in order — each one builds on the previous.

1

Check if the dev server is actually running

Open your terminal and confirm your framework is listening. Look for a line like "ready on http://localhost:3000".

2

Find and kill the conflicting process on port 3000

Use lsof to identify the PID hogging the port, then kill it cleanly.

# macOS / Linux
lsof -ti:3000 | xargs kill -9

# Windows (PowerShell)
Get-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess | Stop-Process -Force
3

Verify the server binds to 0.0.0.0 (not just 127.0.0.1)

If you’re using Docker, WSL, or remote dev, the server must bind to all interfaces.

next dev -H 0.0.0.0 -p 3000
# or in code:
app.listen(3000, '0.0.0.0', () => console.log('ready'))
4

Check for firewall or antivirus blocks

On Windows, allow Node.js through Windows Defender Firewall. On macOS, grant the terminal Full Disk Access on first run.

5

Restart the server and reload the browser

Hard-reload with Ctrl+Shift+R (or Cmd+Shift+R) to bypass cached failed connections.

Did this fix your issue?

1,284 people found this helpful · last vote 3 min ago

94% success rate based on 1,284 votes