EADDRINUSE: Port Already in Use Error
Fix 'EADDRINUSE: address already in use' errors. Learn how to find and kill processes using a port, or configure port fallbacks.
What Does This Error Mean?
The EADDRINUSE error means the network port your application is trying to bind to is already occupied by another process. Each port can only be used by one process at a time.
Common Causes
Another instance of your app is already running
Previous process did not exit cleanly (zombie process)
Another application (like Apache, Nginx, or Docker) is using the port
IDE or dev server from a previous session is still running
Port configured in a range that conflicts with system services
How to Fix It
Find and kill the process on the port
Identify the process ID using the port and terminate it.
# Windows netstat -ano | findstr :3000 taskkill /PID <PID> /F # Linux/macOS lsof -i :3000 kill -9 <PID> # or fuser -k 3000/tcp
Use a different port
Change the port your application listens on.
# Node.js: use environment variable const PORT = process.env.PORT || 3000 app.listen(PORT) # Next.js npx next dev -p 3001 # Docker: map different host port docker run -p 8080:3000 myapp
Set SO_REUSEADDR
Allow immediate port reuse after process termination.
// Node.js: enable SO_REUSEADDR
const server = app.listen(3000)
server.on("listening", () => {
server.address()
})
// By default, Node.js enables SO_REUSEADDR on macOS and LinuxUse port fallback logic
Automatically try the next available port if the default is taken.
function startServer(port, maxAttempts = 10) {
const tryPort = (p) => {
app.listen(p).on("error", (err) => {
if (err.code === "EADDRINUSE" && p < port + maxAttempts) {
console.log(`Port ${p} in use, trying ${p + 1}`)
tryPort(p + 1)
} else {
throw err
}
})
}
tryPort(port)
}Related Tools
Use these tools to debug and fix this error:
Related Errors
Other common errors in this category:
401 Unauthorized Error
Learn what a 401 Unauthorized error means, common causes, and how to fix authentication failures in your web applications.
403 Forbidden Error
Learn what 403 Forbidden means, how it differs from 401, and how to fix access denied errors in your applications.
404 Not Found Error
Learn what 404 Not Found means, common causes, and how to fix broken links and missing resources on your website or API.
429 Too Many Requests Error
Learn what 429 Too Many Requests means, how rate limiting works, and how to handle or avoid hitting API rate limits.