Video

How to Find a Process Using a Port in Linux | lsof and ss Explained

How to Find a Process Using a Port in Linux | lsof and ss Explained

"Address already in use." Your Rails server will not start, the error names the port, and it never names the process holding it. This video shows you how to find that process, confirm what it is, and stop it safely.

What you will learn:
- What a network port actually is, and why a bind gets refused
- Why the same address and port pair cannot be taken twice
- How to go from a port number to a process name to a PID
- lsof for process details, and how to read every column of its output
- ss for socket inspection, and what the Process column is telling you
- Why sudo changes what you can see
- How to inspect a process with ps before you touch it
- SIGTERM vs SIGKILL, and why graceful termination comes first

Commands covered:
sudo lsof -i :3000
sudo ss -ltnp 'sport = :3000'
ps -fp 2381
kill -TERM 2381
kill -9 2381

Chapters:
00:00 - The port conflict problem
00:10 - Why ports become occupied
00:25 - Processes and PIDs
00:40 - Finding the process with lsof and ss
01:00 - A full Rails example, start to finish
01:25 - Benefits and safety precautions
01:45 - Key takeaway

A note on PIDs: they are assigned fresh on every run. The 2381 in this video is illustrative. Always re-check before you stop anything. And if your Rails server is managed by a process supervisor, stop it through its manager rather than killing the process directly.

#Linux #DevOps #lsof #Ruby #RubyOnRails #BackendDevelopment #SysAdmin #Networking #Terminal #CommandLine

— #Astmation —
#software #systems, #automation, and #AI-powered #applications.
Build. Automate. Evolve.
https://astmation.com/


Watch on YouTube

Back to videos