Node Error: listen EADDRINUSE: address already in use :::5000 on Mac M1

Developers using Mac M1 with macOS Monterey might encounter a frustrating issue when running a local Node.js project. The common error listen EADDRINUSE: address already in use :::5000 appears when you try to execute npm run dev. This error indicates that port 5000, which you’re attempting to use for your Node.js application, is already occupied by another process.

Diagnosing the Issue

Before diving into solutions, it’s crucial to understand what’s happening. The EADDRINUSE error is a network-related error that occurs when a TCP/IP port that your application wants to use is already being used by another application or service.

Finding the Culprit Process

The first step is to identify the process that’s using port 5000. You can find the Process ID (PID) of the offending process with this terminal command:

sudo lsof -PiTCP -sTCP:LISTEN

This command lists all processes that are listening on TCP ports. Look for the one that mentions :5000 (you might need to scroll through the list). Once you find it, note the PID.

Killing the Offending Process

If you determine that the process using port 5000 is not critical or if it’s just another instance of your Node application that didn’t close properly, you can terminate it with the following command:

bashCopy codekill -9 PID

Replace PID with the actual Process ID number you found earlier. This forcefully stops the process, freeing up port 5000.

Dealing with macOS Monterey and AirPlay Receiver

A common and less obvious culprit for this issue on macOS Monterey is the AirPlay Receiver service, which, by default, listens on ports 5000 and 8000. If you’re not using your Mac for AirPlay purposes, you can disable this service.

How to Disable AirPlay Receiver:

  1. Open System Preferences.
  2. Click on Sharing.
  3. Uncheck the AirPlay Receiver option.

By disabling the AirPlay Receiver, you free up ports 5000 and 8000, potentially resolving the EADDRINUSE error without having to kill any processes.


Encountering port conflicts is a common issue in development, especially with newer macOS versions where some services utilize popular development ports like 5000 and 8000. By following these steps, you can quickly troubleshoot and resolve the listen EADDRINUSE: address already in use :::5000 error, ensuring a smoother development experience on your Mac M1. Remember, always verify which process you’re stopping to avoid inadvertently closing critical system or application processes.

Leave a Reply

Your email address will not be published. Required fields are marked *