Be the first user to complete this post

  • 0
Add to List

Resolved - Error: listen eaccess using nodejs and pm2

I bumped into this issue when trying to run my node application using pm2. From my understanding, a combination of the following factors causes the issue

  • pm2 usually needs to be installed globally, which means more than likely you installed it using sudo. Therefore you need sudo to run the command itself.
  • If your node application needs to listen on port 80, you're gonna need root access.
The way I was able to get around it was by logging in as root and then executing the pm2 command as usual. If your current user has root access, you can easily login as root on an ubuntu machine through the following command
sudo su
Once you are root, you might realize 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 personally endorse letting nodejs listen on port 80. You're better off setting up NGINX to listen on port 80 which forwards requests to your node process which actually listens on another port. If you're not sure how to set that up, you will find this post helpful.



Also Read:

  1. nodejs: generate uuid / guid
  2. Understanding semver versioning for your nodejs packages
  3. Find the environment variables of a nodejs process in linux
  4. Error: can not find module 'underscore'
  5. Error: can not find module 'underscore'
  6. Access the request body of a post request in your nodejs - expressjs app.
  7. Configuring jshint as a pre-commit hook for your nodejs applications
  8. Accessing the request body and session in nodejs using express