MacOS Monterey Node Port 9000 Refused

I’ve been working on a React App for months that connects on localhost port 9000. Recently the app stopped working after an upgrade to Monterey. Turns out the upgrade also required a number of services to be re-installed via brew. One of those services, php-fpm, is now taking over port 9000 automatically on startup despite not having explicitly set the updated PHP version to run at start.

As such, opening http://localhost:9000/ on the browser was routing to PHP apps and not the node app I was looking for.

MacOS Listing Port Usage

The first step to finding what other services might be fighting with the node app is to run the lsof command.

sudo lsof -i :9000

The :9000 should be replaced with whichever port you are investigating. Port 9000 is the default for most node servers.

In my case the results looked like this:

This tells us that php-fpm will first answer any port 9000 queries on IPV4 localhost.

Node server has been relegated to only answer port 9000 on IPV6.

The node server on IPV6 can be verified by pointing the browser to http://[::1]:9000/ and connecting to the app.

[::1] is the IPV6 syntax for localhost.

Listing Homebrew Services

To stop the php-fpm service it needs to be managed via brew since that is where I started the service from in the first place. The service php-fpm does not exist, so what is calling it? Let’s check brew services…

brew services list

Turns out is is the php@7.4 service causing the issue.

Stopping Brew Services

Now that we know which service is fighting with node server we can stop it.

brew services stop php@7.4

That stops php-fpm from intercepting port 9000 traffic on localhost and the original http://localhost:9000 access I was running previously is now back in action.

Leave a Reply

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