Skip to content

Get Node.js Port Using PM2 Name

View on Twitter

💡 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,}'.

Download the VPS Security Cheatsheet

Use this FREE security cheatsheet to not miss a step when securing your VPS.

A preview of the VPS Security Cheatsheet.

You'll also get tips on building scalable Node.js applications about twice a month. I respect your email privacy. Unsubscribe any time.

You might also like
List Globally Installed NPM Libraries Read tip
Cron Jobs With Github Actions Read tip
Practical Guide to Amazon Web Services Read tip