Get Node.js Port Using PM2 Name
💡 I recently needed to get the port of a @nodejs process from its PM2 name with a one-liner:
➡️ ss -ntlp | grep $(pm2 ls | grep <app_name> | awk '{print $12}') | awk '{print $4}' | grep -oP '(?<=:)[0-9]{2,}'
![Get the port of a running Node.js process by its PM2 Name with the following command: ss -ntlp | grep $(pm2 ls | grep <app_name> | awk '{print $12}') | awk '{print $4}' | grep -oP '(?<=:)[0-9]{2,}'.](/images/tips/get-nodejs-port-using-pm2-name.jpg)

Download the VPS Security Cheatsheet
No spam! 🙅🏻♀️ Unsubscribe at any time.