Skip to content

Instantly share code, notes, and snippets.

@mreinstein
Created August 2, 2017 17:15
Show Gist options
  • Select an option

  • Save mreinstein/cd3065621aa130d8131d8f2e502e6beb to your computer and use it in GitHub Desktop.

Select an option

Save mreinstein/cd3065621aa130d8131d8f2e502e6beb to your computer and use it in GitHub Desktop.
determine the TCP port on which a node.js program listens

Find the pid of the running process if you don't know it:

$ ps ax | grep node
1012 ?        Ssl    0:03 node /usr/bin/signalhub listen -p 8000

In this case we're running a node program and it's pid is 1012

$ lsof -Pan -p 1012 -i
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
node    1012 ubuntu   10u  IPv6  15437      0t0  TCP *:8000 (LISTEN)

Ahh, this program is listening on port 8000 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment