本地启动服务一直报错:
Description: Web server failed to start. Port 8021 was already in use. Action: Identify and stop the process that's listening on port 8021 or configure this application to listen on another port.
排查占用8021的进程
# 使用命令
sudo lsof -i :8021
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
launchd 1 root 40u IPv4 0xe1fc8d3044233469 0t0 TCP localhost:intu-ec-client (LISTEN)
launchd 1 root 41u IPv6 0xe1fc8d26b1acd419 0t0 TCP localhost:intu-ec-client (LISTEN)
launchd 1 root 42u IPv4 0xe1fc8d3044233469 0t0 TCP localhost:intu-ec-client (LISTEN)
launchd 1 root 43u IPv6 0xe1fc8d26b1acd419 0t0 TCP localhost:intu-ec-client (LISTEN)
发现占用的PID
是1
,即系统的 launchd
进程
因为launchd
进程会根据所在的 /Library/LaunchDaemons
和 /Library/LaunchAgents
目录中的配置文件来管理各个服务或应用,扫描文件找到服务,当然这个目录也可能是/System/Library/LaunchAgents
和/System/Library/LaunchDaemons
grep -rl "intu" /Library/LaunchAgents
grep -rl "intu" /Library/LaunchDaemons
grep -rl "8021" /System/Library/LaunchAgents
grep -rl "8021" /System/Library/LaunchDaemons
# 最后一个找到了包含8021的服务列表
/System/Library/LaunchDaemons/com.apple.airportd.plist
/System/Library/LaunchDaemons/com.apple.eapolcfg_auth.plist
/System/Library/LaunchDaemons/com.apple.ftp-proxy.plist
再次筛选:
grep -rl ">8021<" /System/Library/LaunchDaemons
# 找到占用8021端口的服务
/System/Library/LaunchDaemons/com.apple.ftp-proxy.plist
卸载服务
# 卸载这个服务,-w表示写入配置,这里整体是禁止下次启动
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.ftp-proxy.plist
评论区