Skip to content

How to find the process that is using a port

Sometimes when developing multiple applications at once, or trying out demos, I end up with multiple programs running on different ports on my computer: 3000, 3001, 1313, and so on.

If I don’t pay close attention, I might forget which application is running on a specific port.

How can we determine which program is listening on a port?

The lsof command helps us do that!

Running

lsof -i :1313

Will tell me the command that’s currently listening on port 1313:

COMMAND  PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
hugo    8698 fla 4764u  IPv4 0xc72ca30d18e45ef9      0t0  TCP localhost:bmc_patroldb (LISTEN)

In this case it’s the hugo command, with PID 8698.

If I want to terminate that program, I can just run kill 8698.


→ Get my Linux Command Line Handbook

→ I wrote 17 books to help you become a better developer:

  • C Handbook
  • Command Line Handbook
  • CSS Handbook
  • Express Handbook
  • Git Cheat Sheet
  • Go Handbook
  • HTML Handbook
  • JS Handbook
  • Laravel Handbook
  • Next.js Handbook
  • Node.js Handbook
  • PHP Handbook
  • Python Handbook
  • React Handbook
  • SQL Handbook
  • Svelte Handbook
  • Swift Handbook
...download them all now!

Also, JOIN MY CODING BOOTCAMP, an amazing cohort course that will be a huge step up in your coding career - covering React, Next.js - next edition February 2025

Bootcamp 2025

Join the waiting list