0

I have created a services that should listen on port 50051, but is is already in use.

So I need to find and kill the listener?

Step 1:

sudo lsof -i tcp:50051                                                                                                                                                                                                  
Password:
COMMAND PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
launchd   1 root   43u  IPv6 0x9cf985f50f0e6545      0t0  TCP *:50051 (LISTEN)
launchd   1 root   44u  IPv4 0x9cf985f50cb5056d      0t0  TCP *:50051 (LISTEN)

Step 2:

find ~/Library/LaunchAgents /Library/LaunchAgents /Library/LaunchDaemons /System/Library/LaunchAgents /System/Library/LaunchDaemons -name "*.plist" -exec defaults read "{}" 2>/dev/null \; | grep --with-filename 50051
(standard input):            SockServiceName = 50051;

Step 3: ?

Note: I am unable to kill the listener as it is started by launchd.

lsof -ti tcp:500051 | xargs kill
Chris G.
  • 157
  • 5

1 Answers1

0

This one did the trick

find ~/Library/LaunchAgents /Library/LaunchAgents /Library/LaunchDaemons /System/Library/LaunchAgents /System/Library/LaunchDaemons -name "*.plist" -exec grep -H 50051 "{}" \; 2>/dev/null
Chris G.
  • 157
  • 5