Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

Resolved — Error: listen eaccess using nodejs and pm2

I bumped into this issue when try­ing to run my node appli­ca­tion using pm2.

From my under­stand­ing, a com­bi­na­tion of the fol­low­ing fac­tors causes the issue

  • pm2 usu­ally needs to be installed glob­ally, which means more than likely you installed it using sudo. There­fore you need sudo to run the com­mand itself.
  • If your node appli­ca­tion needs to lis­ten on port 80, you’re gonna need root access.

The way I was able to get around it was by log­ging in as root and then exe­cut­ing the pm2 com­mand as usual.

If your cur­rent user has root access, you can eas­ily login as root on an ubuntu machine through the fol­low­ing command

sudo su

Once you are root, you might real­ize that you need to install node/nvm as well in the root user as well in case it wasn’t installed already.

NOTE: I don’t per­son­ally endorse let­ting nodejs lis­ten on port 80. You’re bet­ter off set­ting up NGINX to lis­ten on port 80 which for­wards requests to your node process which actu­ally lis­tens on another port. If you’re not sure how to set that up, you will find this post help­ful.

Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.