#

How to Fix EADDRINUSE Error in Node.js (Port 9000 Already in Use)

Illustration showing a Node.js server error where port 9000 is already in use


If you’ve ever started a Node.js or Express app and been greeted by this message:

Error: listen EADDRINUSE: address already in use :::9000

Take a breath.


This is one of the most common Node.js errors, especially during development. It doesn’t mean your code is broken. It simply means port 9000 is already being used by another process.


In this guide, you’ll learn:

  1. What EADDRINUSE actually means
  2. Why it happens so often in Node.js projects
  3. Multiple safe ways to fix it (development & production)
  4. Best practices to prevent it from happening again


Let’s walk through it step by step.

What Does EADDRINUSE Mean in Node.js?

EADDRINUSE stands for Error: Address In Use.


When your application runs code like this:

app.listen(9000);

Node.js asks the operating system for permission to listen on port 9000. If another process is already listening on that port, the OS refuses — and Node throws the EADDRINUSE error.


Only one process can listen on a port at a time.


Node.js server.listen() documentation.

Common Causes of the EADDRINUSE Error

This error usually happens for very normal reasons:

  1. Your app is already running in another terminal
  2. A previous Node process didn’t shut down correctly
  3. You’re using nodemon, pm2, or a file watcher
  4. Another project is using the same port
  5. A hosting environment (Docker, cPanel, cloud VM) has the port reserved


In short: the port is busy, not broken.

Solution 1: Find What’s Using Port 9000 (Linux & macOS)

First, identify the process holding the port:

lsof -i :9000

lsof command reference.


You’ll see output similar to:

node 24531 user 23u IPv6 TCP *:9000 (LISTEN)

The key value here is the PID (24531).


Stop that process:

kill -9 24531

Once it stops, port 9000 becomes available again.

Solution 2: Stop Existing Node Processes (PM2 or Nodemon)

If you’re using PM2 process manager:

pm2 list
pm2 stop <id | name>

PM2 quick start guide


If you’re using nodemon file watcher:

  1. Check for another open terminal
  2. Stop the running process with CTRL + C


Then restart your app normally.


Solution 3: Use Environment Variables for the Port (Best Practice)

Hard‑coding ports is fine for demos, but not ideal for real projects.


A better approach:

const PORT = process.env.PORT || 9000;


app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});


Now you can run your app on a different port when needed:

PORT=9001 npm start


This is essential for:

  1. Production deployments
  2. Docker containers
  3. Cloud platforms (Heroku, Railway, Render)
  4. Shared hosting environments


Your app becomes flexible and deployment‑friendly.

Solution 4: Fixing EADDRINUSE on cPanel or Shared Hosting

On managed hosting platforms:

  1. Ports may already be assigned internally
  2. Restart the app via Node.js App Manager
  3. Use the port provided by the hosting environment
  4. Let the reverse proxy handle public traffic


Never assume a port is free on shared infrastructure.


cPanel Node.js application setup guide.

How to Prevent EADDRINUSE in the Future

A few good habits go a long way:

  1. Always stop Node processes before restarting
  2. Avoid hard‑coding ports
  3. Use environment variables consistently
  4. Monitor running processes during development
  5. Use process managers like PM2 correctly


These small practices save hours over time.


Is EADDRINUSE a Serious Error?

No.


It’s not a bug in your logic or your framework. It’s simply Node.js protecting system resources.

Once you understand how ports work, this error becomes easy to diagnose and quick to fix.

So next time when Node.js tells you:

Address already in use

It’s not rejecting your work — it’s asking you to choose a clear path.


Free the port, choose another one, or let the environment decide.


Your application will run.

Share this: