Skip to content
Maxim Orlov Logo

Helping Node.js developers write robust applications 🚀

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,}'.
A preview of the VPS Security Cheatsheet.

Download the VPS Security Cheatsheet

No spam! 🙅🏻‍♀️ Unsubscribe at any time.