Something is already running on port 3000. mac

by John H
2 minutes

I have a node app that has to run on localhost:3000 but my mac keeps saying that something is running on port 3000. When I run netstat or lsof and check for running programs on port 3000 I get nothing. When I was ran yarn start or npm run and it prompted to run on a different port node was able to get the app running, however it is a NECESSITY that it run at localhost:3000

So The Fix (to my issue

let me preface this fix to say that I develop on many different platforms and systems on my mac. Most of my systems are LAMP projects, either custom PHP or Wordpress or Laravel and I use MAMP almost exclusively for building and developing on those code bases. I used to run my php projects without MAMP a few years ago, mostly using Homebrew for deving, this required manually editing my hosts file - but since moving to MAMP my need for editing my hosts file is gone - MAMP handles it. Until now.

So why is my port blocked for localhost? Why isn't 3000 available? Why can't node serve to 3000? The answer for me was in the hosts file.

Open your dev boxes hosts file - mine was at /etc/hosts

sudo nano /etc/hosts

My file had an entry that looked like this localhost

Wait - shouldn't there be a '1' there?
So I added the 1 and saved (ctrl x - and yes to save) localhost

and then started my app

yarn start

and it worked. Localhost wasn't able to resolve and in the end that was causing the port to look occupied. UGH

Related Articles

Installing Yarn on Mojave

I was unable to install yarn directly - I had to do a few additional steps for it to actually...

John H John H
~1 minute

Hashtag Searching on Popular Social Networks

John H John H
~1 minute

Blocking Access to a Url route in Apache

This serves a 403 forbidden for any route with blog. RewriteRule ^(.*/)?blog(.*/)?/ - [F,L]...

John H John H
~1 minute