Find owner of port

Show which process owns a port; -nP skips DNS/service name lookups for speed

lsof -nP -i :<port>

tool
lsof19 commands
tags
lsofnetworktroubleshootingdebug

More lsof commands

  • lsof -nP -iTCP -sTCP:LISTEN

    List every TCP listener with PID, no name resolution; modern: ss -ltnp

  • lsof +L1

    Find unlinked files still held open eating disk; df shows full but du does not

  • lsof /mnt/<name>

    Reveal processes blocking a 'device busy' umount; pass the mountpoint path

  • lsof -t -i:<port> | xargs -r kill

    Kill whatever owns a port; -t prints bare PIDs, -r avoids running kill on empty input

  • lsof -nP -i -sTCP:CLOSE_WAIT

    Spot sockets the app forgot to close; growing CLOSE_WAIT = fd/connection leak

all 19 lsof commands