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
    101 Ways to Make Your Website More Awesome Read tip
    Easily Customise Your Shell Prompt Read tip
    Playground Application for JavaScript and Node.js Read tip