Reputation: 5659
I have a small Java ServerSocket application that is running on port 4444. I wanted to see the process using that port in my OSX terminal, and my first thought was to do the following:
netstat -a | grep 4444
however, this doesn't give me any results.
lsof -i :4444
and I get the following (correct) result:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 66389 admin 18u IPv6 0x1ae123a422ebe931 0t0 TCP *:krb524 (LISTEN)
Could someone tell me why netstat doesn't show the port but lsof does?
Upvotes: 2
Views: 6482
Reputation: 550
Netstat probably does list your task, but with an alias 'krb524' instead of the port number. Those aliases are listed in /etc/services
.
$ grep 4444 /etc/services
krb524 4444/udp # KRB524
krb524 4444/tcp # KRB524
To see just port numbers with netstat, add the -n
parameter.
netstat -a -n | grep 4444
Upvotes: 2