Error: listen EADDRINUSE: address already in use :::3000
Node.js · updated 2026-11-05
Thrown as an unhandled 'error' event the moment server.listen() runs, so the app exits during startup. The ':::3000' part is the IPv6 wildcard address, which on most systems also covers IPv4.
node:events:497
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (node:net:1908:16)
at listenInCluster (node:net:1965:12)
at Server.listen (node:net:2067:7)
at file:///app/server.js:14:8 {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 3000
}Quick fix
Find and stop whatever already holds port 3000, then start the server again. On macOS or Linux, lsof prints the PID of the listener; kill it, or pick a different PORT. If an orphaned dev server keeps coming back, fix the restart flow that leaves the old process alive.
- Run lsof -nP -iTCP:3000 -sTCP:LISTEN (macOS/Linux) or netstat -ano | findstr :3000 (Windows).
- Check what that PID is with ps -p <PID> -o command.
- Stop it with kill <PID>; use kill -9 only if it ignores SIGTERM.
- Read the port from process.env.PORT so switching needs no code change.
- Handle SIGTERM and SIGINT by calling server.close() so restarts release the port.
# Who is listening on 3000?
lsof -nP -iTCP:3000 -sTCP:LISTEN
# Ask it to exit (replace 12345 with the PID from above)
kill 12345
# Linux alternative: kill whatever owns the port
fuser -k 3000/tcpPaste this into Claude Code, Cursor or Codex in the project that throws it. The agent reads this guide in plain text and applies the fix that matches your stack.
Read https://runheed.com/errors/eaddrinuse.md and fix this error in this project.Why it happens
An old copy of the server is still running
A closed terminal tab, a crashed editor or a detached watcher (nodemon, tsx watch) can leave the previous server alive in the background. That process still owns the listening socket, so the new one cannot bind to the same port.
A child process survived its parent
Tools that spawn a worker to serve requests (next start, cluster workers, some dev servers) can leave the child running when only the parent gets killed. Process managers need tree-kill behavior, otherwise the orphaned child keeps the port.
Another program already uses that port
A Docker container published with -p 3000:3000, a second project, or a system service is listening there. On recent macOS versions, AirPlay Receiver occupies ports 5000 and 7000, which trips up Flask-style defaults and some Node setups.
listen() called twice in the same process
The app module calls app.listen() at import time and the entry file or test suite calls it again. Hot-reload setups that re-run the module without closing the previous server hit the same wall on every reload.
Overlapping restarts in production
A deploy script starts the new process before the old one has released the port, or two pm2 or systemd units point at the same app. Without a graceful shutdown, the old process can hold on for its full kill timeout.
Other fixes
- In tests, export the app without calling listen and use listen(0) so each test file gets a free random port.
- Under pm2, enable treekill with a kill_timeout so worker children die with the parent.
- Listen for server.on('error') and print a clear 'port in use' message instead of the raw unhandled event.
- Turn off AirPlay Receiver in macOS System Settings if it holds port 5000 or 7000.
Same error, other wording
- Error: listen EADDRINUSE :::3000
- Error: listen EADDRINUSE: address already in use 0.0.0.0:3000
- Error: listen EADDRINUSE: address already in use 127.0.0.1:8080
Let your coding agent catch the next one
Runheed records this error in production with the stack trace, the breadcrumbs before it and, when you set it, the agent session that shipped the code, and serves it to Claude Code, Cursor or any MCP client. With it connected, you can ask:
> Look up the EADDRINUSE crashes from the last deploy, tell me which port and host they hit, and add a SIGTERM handler that closes the HTTP server before exit.
Setup for Node.js and Express or Vercel Functions, then have your agent fix and resolve it.
Related errors
- Error: connect ECONNREFUSED 127.0.0.1:5432
- [UnhandledPromiseRejection: This error originated either by throwing inside of an async...
- FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
More in Memory, async and the process
- RangeError: Maximum call stack size exceededNode.js
- RecursionError: maximum recursion depth exceededPython
- RuntimeError: Event loop is closedPython
- RuntimeWarning: coroutine 'fetch_user' was never awaitedPython
- OSError: [Errno 98] Address already in usePython
- Error: error:0308010C:digital envelope routines::unsupportedNode.js
- MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error...Node.js
- Error: ENOENT: no such file or directory, open '/app/config.json'Node.js
- Error: EACCES: permission denied, open '/app/data/cache.json'Node.js
- Error: EMFILE: too many open files, open '/app/uploads/0412.jpg'Node.js
- PermissionError: [Errno 13] Permission denied: '/app/data/report.csv'Python
- CredentialsProviderError: Could not load credentials from any providersNode.js
- botocore.exceptions.NoCredentialsError: Unable to locate credentialsPython
- django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.Python
Other error topics
- Error: write EPIPENetwork and HTTP
- BrokenPipeError: [Errno 32] Broken pipeNetwork and HTTP
- Error: read ECONNRESETNetwork and HTTP
- django.db.utils.OperationalError: no such table: orders_orderDatabases
- error: null value in column "total" of relation "orders" violates not-null constraintDatabases
- PrismaClientKnownRequestError: Unique constraint failed on the fields: (`email`)Databases
- Module not found: Can't resolve 'fs'Imports and modules
- AttributeError: module 'requests' has no attribute 'get'Imports and modules
- TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /app/src/index.tsImports and modules
- Failed to find Server Action "7f3a9c2e5d1b4a6f8c0e2d7b9a1c3e5f7d9b0a2c4e". This request...React and Next.js rendering
- Error: Event handlers cannot be passed to Client Component props.React and Next.js rendering
- Too many re-renders. React limits the number of renders to prevent an infinite loop.React and Next.js rendering
- UnboundLocalError: cannot access local variable 'total' where it is not associated with a...Undefined, None and type errors
- System.NullReferenceException: Object reference not set to an instance of an object.Undefined, None and type errors
- AttributeError: 'NoneType' object has no attribute 'x'Undefined, None and type errors
- TypeError: Object of type datetime is not JSON serializableJSON, parsing and validation
- SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSONJSON, parsing and validation
- ZodError: [ { "expected": "string", "code": "invalid_type", "path": [ "email" ]...JSON, parsing and validation
- MCP error -32602: Input validation error: Invalid arguments for tool get_orderMCP servers and clients
- Not Acceptable: Client must accept both application/json and text/event-streamMCP servers and clients
- Bad Request: Unsupported protocol version: 2026-07-28MCP servers and clients
Free tools: Source map stack trace decoder · Uptime and SLA downtime calculator · Error budget calculator · Stack trace formatter · JSON log viewer · HTTP status code reference.
References: Node.js net module: server.listen(), Node.js errors: common system errors
Spotted a mistake? Email hello@greatwork.company. About Runheed.