Identifying ports already in use

$ lsof -i -n -P | grep TCP | grep 4000
beam.smp  28569 mnishiguchi   49u  IPv4 0x4d3d8b73de14af89      0t0  TCP *:4000 (LISTEN)

$ kill -9 28569

Resources