Skip to content
Node.js and Python3 min read

Error: listen EADDRINUSE: address already in use

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

Short answer

EADDRINUSE means your Node.js app tried to listen on a port that another process is already using, often an older copy of the same app. Find the process with `lsof -i :3000`, stop it with `kill`, or start the app on another port; on managed hosting, listen on `process.env.PORT` instead of a fixed number.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. Causes
  2. How to fix it on your computer
  3. How to fix it on a server
  4. A similar error: EACCES on port 80
  5. Prevention
  6. On ArabyHost

A port can be held by only one listening process at a time. When server.listen() or app.listen() asks for a port that’s taken, Node.js throws EADDRINUSE and the app exits before serving a single request. The number at the end of the message is the port in question.

Causes

  • An older copy of your app is still running, in another terminal, in the background, or left behind after a crash.
  • nodemon or another watcher restarts too fast, before the previous process releases the port.
  • Two parts of the code call listen(), for example both app.js and server.js, or a test file that starts the server again.
  • Another program uses the same port: a second project, a database admin tool, a Docker container on your PC.
  • On hosting, the app is started twice: once by the hosting’s app server and once manually over SSH, or with a hard-coded port instead of the one the platform assigns.

How to fix it on your computer

  1. Find what holds the port (macOS and Linux):

    lsof -i :3000

    The PID column shows the process ID. On Windows use netstat -ano | findstr :3000.

  2. Stop that process:

    kill 12345        # replace with the PID
    kill -9 12345     # only if it refuses to stop

    On Windows: taskkill /PID 12345 /F.

  3. Or use another port for this run: PORT=3001 npm start, with your code reading the variable:

    const port = process.env.PORT || 3000;
    app.listen(port, () => console.log(`Listening on ${port}`));
  4. Close the server on shutdown so restarts are clean:

    const server = app.listen(port);
    process.on('SIGTERM', () => server.close(() => process.exit(0)));
    process.on('SIGINT', () => server.close(() => process.exit(0)));
  5. Search the code for more than one listen( call and keep only one entry point.

How to fix it on a server

On a hosting account you see only your own processes. Find stray copies with ps aux | grep node and stop them with kill PID. If a process manager such as PM2 keeps restarting an old copy, stop it there (pm2 delete app-name) rather than killing it by hand.

When the app runs behind an application server such as Phusion Passenger, you don’t choose the port at all: the server passes it in process.env.PORT. Hard-coding 3000 there, or starting node app.js yourself next to it, is a classic source of this error and of Passenger startup errors.

A similar error: EACCES on port 80

Don’t confuse this with Error: listen EACCES: permission denied 0.0.0.0:80. There the port is free, but your user isn’t allowed to open it, because ports below 1024 need administrator rights on Linux. Use a port above 1024 while developing, and in production let the web server handle ports 80 and 443 in front of your app.

Prevention

  • Always read the port from process.env.PORT, with a fallback only for local work.
  • Start each app from a single entry file.
  • Handle shutdown signals and close the server.
  • Run one process manager per app, not several.

On ArabyHost

On ArabyHost AI/Developer plans, Node.js 20 and 24 apps run through cPanel’s Setup Node.js App (the CloudLinux selector with Phusion Passenger). It starts the app and passes the port automatically, so your code must listen on process.env.PORT. Restart the app from that page instead of launching a second copy over SSH. The Node.js deployment guide walks through the setup, and the AI/Developer hosting page lists what’s included.

FAQ

What does ::: mean in :::3000?

`::` is the IPv6 "any address", so `:::3000` means port 3000 on all network interfaces. On most systems that also covers IPv4, which is why any process on port 3000 blocks it.

Is kill -9 safe?

It ends the process immediately without letting it clean up, so try a plain `kill` first. Use `kill -9` only when the process ignores the normal signal.

Why does it happen every time nodemon restarts?

The old process hasn't released the port before the new one starts, often because the app doesn't close its server on shutdown. Handle `SIGTERM`/`SIGINT` and call `server.close()`, or add a short delay in nodemon's settings.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.