前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >macos排查并禁用系统占用的8021端口

macos排查并禁用系统占用的8021端口

作者头像
阿超
发布2024-03-12 13:29:55
1280
发布2024-03-12 13:29:55
举报
文章被收录于专栏:快乐阿超快乐阿超

不要为了尖锐的批评而生气,真理总是不合口味的。——高尔基

本地启动服务一直报错

代码语言:javascript
复制
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.

然后一查

代码语言:javascript
复制
# 扫描端口占用
GithubIireAchao:blog achao$ sudo lsof -i :8021
Password:
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)

发现占用的PID1,即系统的 launchd 进程

因为launchd 进程会根据所在的 /Library/LaunchDaemons/Library/LaunchAgents 目录中的配置文件来管理各个服务或应用,扫描文件找到服务,当然这个目录也可能是/System/Library/LaunchAgents/System/Library/LaunchDaemons

代码语言:javascript
复制
GithubIireAchao:LaunchAgents achao$ grep -rl "intu" /Library/LaunchAgents
GithubIireAchao:LaunchAgents achao$ grep -rl "intu" /Library/LaunchDaemons
GithubIireAchao:LaunchDaemons achao$ grep -rl "8021" /System/Library/LaunchAgents
# 找到了包含8021的服务列表
GithubIireAchao:LaunchDaemons achao$ grep -rl "8021" /System/Library/LaunchDaemons
/System/Library/LaunchDaemons/com.apple.airportd.plist
/System/Library/LaunchDaemons/com.apple.eapolcfg_auth.plist
/System/Library/LaunchDaemons/com.apple.ftp-proxy.plist

可以挨个查看,也可以再次筛选,例如使用">8021<"等来筛选

代码语言:javascript
复制
GithubIireAchao:LaunchDaemons achao$ grep -rl "<string>8021</string>" /System/Library/LaunchDaemons
/System/Library/LaunchDaemons/com.apple.ftp-proxy.plist

卸载这个服务,-w表示写入配置,这里整体是禁止下次启动

代码语言:javascript
复制
GithubIireAchao:LaunchDaemons achao$ sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.ftp-proxy.plist

再次查看端口

代码语言:javascript
复制
GithubIireAchao:LaunchDaemons achao$ sudo lsof -i :8021
GithubIireAchao:LaunchDaemons achao$ 
本文参与?腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2024-03-11,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客?前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体分享计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com