Finding What's Listening on Your Ports


A common frustration: you start a server and get “address already in use.” Something is already bound to that port, but you left it running in another terminal and forgot about it. Here are the tools to diagnose it quickly.

Find what’s occupying a specific port

lsof -i :8080

This lists all processes with an open file descriptor on port 8080, including the process name, PID, and user — enough to identify and kill the culprit.

List all listening ports on the machine

netstat -an | grep LIST

List all ports with active connections

netstat -an | grep EST

Find Java processes

jps

jps is a JDK utility that lists running JVM processes with their main class names — more readable than grep-ing through ps output when you’re working with multiple Java services.

List all running processes

ps ax