MacOS – Trying to close open port 5900 or find process that opened it

macosremote desktop

On a Mac Pro 2013 running High Sierra I have discovered that port 5900 remains opened which is a "VNC remote desktop". I do run TeamViewer but have turned it off & confirmed it being off with activity monitor. On Terminal I have tried (see below). I really don't want this port simply being opened all the time.

patobrien$ sudo lsof -i :5900
Password:
COMMAND PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
launchd   1 root    8u  IPv4 0xb6a6e03f8b5bc76d      0t0  TCP *:rfb (LISTEN)
launchd   1 root   13u  IPv6 0xb6a6e03f8b5b5d7d      0t0  TCP *:rfb (LISTEN)
launchd   1 root   20u  IPv6 0xb6a6e03f8b5b5d7d      0t0  TCP *:rfb (LISTEN)
launchd   1 root   25u  IPv4 0xb6a6e03f8b5bc76d      0t0  TCP *:rfb (LISTEN)
 patobrien$ sudo kill -9 1
kill: 1: Operation not permitted

Best Answer

TeamViewer is a proprietary protocol not the same as VNC. However, macOS has screen sharing (VNC) built-in. Turn it off in System Preferences->Sharing->Screen Sharing:

enter image description here