Skip to content

Find the PID of the process that use a specific port

How many times did you tried to search how to find the PID for process which is running in a specific port. I face this problem at least once per week. Sometimes I close VS Code directly without closing the running processes from integrated terminal.

The command below works perfectly for Linux and MAC OS users

lsof -n -i :PORT

For example, if you’re trying to find the PID of the process running on port 3000 simply run this:

lsof -n -i :3000

Explanation of command

Let’s come back to our command and see how exactly get the PID for the port specified:

-n no host names
-i i select by IPv[46] address: [46][proto][@host|addr][:svc_list|port_list]

If you have a similar question and you want to have a response from me. Please write me in comments and I’ll answer soon.

Published inTutorials

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *