Openclaw 插件突然要跑特定端口,导致无法连接的问题处理

发布时间:2026/5/19 18:09:32

Openclaw 插件突然要跑特定端口,导致无法连接的问题处理 问题描述Network error: [TypeError: fetch failed] { [cause]: ConnectTimeoutError: Connect Timeout Error (attempted address: 10.0.0.9:7897, timeout: 10000ms)问题排查1. env环境变量env | grep -i proxy返回是空即不是这个问题导致2. 核心判断先跑如下命令ps -ef | grep openclaw | grep -v grep avahi 926 1 0 18:18 ? 00:00:03 avahi-daemon: running [openclaw.local] user 9249 1249 0 18:36 ? 00:00:00 openclaw user 9256 9249 0 18:36 ? 00:00:37 openclaw-gateway记下 PID比如 9249然后cat /proc/9249/environ | tr \0 \n | grep -i proxy HTTP_PROXYhttp://10.0.0.9:7897/ HTTPS_PROXYhttp://10.0.0.9:7897/ NO_PROXYlocalhost,127.0.0.0/8,::1 ALL_PROXYsocks://10.0.0.9:7897/ http_proxyhttp://10.0.0.9:7897/ https_proxyhttp://10.0.0.9:7897/ no_proxylocalhost,127.0.0.0/8,::1 all_proxysocks://10.0.0.9:7897/根因确认openclaw 启动时带了代理环境变量执行pkillopenclaw:~$ pkill openclaw openclaw:~$ openclaw:~$ openclaw:~$ ps -ef | grep -i openclaw avahi 926 1 0 18:18 ? 00:00:00 avahi-daemon: running [openclaw.local] user 5642 1249 2 18:27 ? 00:00:00 openclaw user 5649 5642 99 18:27 ? 00:00:04 openclaw-gateway user 5683 2938 0 18:27 pts/1 00:00:00 grep --colorauto -i openclaw openclaw:~$ cat /proc/5642/environ | tr \0 \n | grep -i proxy HTTP_PROXYhttp://10.0.0.9:7897/ HTTPS_PROXYhttp://10.0.0.9:7897/ NO_PROXYlocalhost,127.0.0.0/8,::1 ALL_PROXYsocks://10.0.0.9:7897/ http_proxyhttp://10.0.0.9:7897/ https_proxyhttp://10.0.0.9:7897/ no_proxylocalhost,127.0.0.0/8,::1 all_proxysocks://10.0.0.9:7897/这说明❗不是旧进程遗留❗不是临时 shell export✅是“启动链条里固定注入的环境变量”核心推断:结合你所有信息可以明确openclaw 是由某个父进程PID 1249启动的现在最关键一步直接定位元凶:运行ps -fp 1249 UID PID PPID C STIME TTY TIME CMD user 1249 1 0 18:18 ? 00:00:00 /usr/lib/systemd/systemd --user很好这一步已经把问题彻底锁死了 最终根因已经确认user 1249 1 ... /usr/lib/systemd/systemd --user openclaw 是被systemd --user用户级 systemd启动的 说明代理变量是在 systemd user 环境里被注入的再执行如下操作openclaw:~$ systemctl --user show-environment | grep -i proxy openclaw:~$因为systemctl --user show-environment | grep -i proxy是空的。但openclaw 进程仍然带 proxy而它的父进程又是systemd --user。这只剩下一种高概率情况proxy 是写在 openclaw 这个 user service 的 unit 里或者它引用的 EnvironmentFile 里。另外你pkill openclaw之后它马上又起来了也说明它大概率就是个systemd user service而且带了自动重启。先跑这几条openclaw:~$ systemctl --user list-units --typeservice | grep -i openclaw systemctl --user list-unit-files | grep -i openclaw openclaw-gateway.service loaded active running OpenClaw Gateway (v2026.3.13) openclaw-gateway.service enabled enabled然后再运行下面指令openclaw:~$ grep -RniE proxy|10\.0\.0\.9|7897 \ ~/.config/systemd/user /etc/systemd/user /usr/lib/systemd/user \ ~/.config/environment.d /etc/environment /etc/profile.d ~/.pam_environment \ 2/dev/null user/.config/systemd/user/default.target.wants/openclaw-gateway.service:16:EnvironmentHTTP_PROXYhttp://10.0.0.9:7897/ user/.config/systemd/user/default.target.wants/openclaw-gateway.service:17:EnvironmentHTTPS_PROXYhttp://10.0.0.9:7897/ user/.config/systemd/user/default.target.wants/openclaw-gateway.service:18:EnvironmentNO_PROXYlocalhost,127.0.0.0/8,::1 user/.config/systemd/user/default.target.wants/openclaw-gateway.service:19:EnvironmentALL_PROXYsocks://10.0.0.9:7897/ user/.config/systemd/user/default.target.wants/openclaw-gateway.service:20:Environmenthttp_proxyhttp://10.0.0.9:7897/ user/.config/systemd/user/default.target.wants/openclaw-gateway.service:21:Environmenthttps_proxyhttp://10.0.0.9:7897/ user/.config/systemd/user/default.target.wants/openclaw-gateway.service:22:Environmentno_proxylocalhost,127.0.0.0/8,::1 user/.config/systemd/user/default.target.wants/openclaw-gateway.service:23:Environmentall_proxysocks://10.0.0.9:7897/ user/.config/systemd/user/openclaw-gateway.service:16:EnvironmentHTTP_PROXYhttp://10.0.0.9:7897/ user/.config/systemd/user/openclaw-gateway.service:17:EnvironmentHTTPS_PROXYhttp://10.0.0.9:7897/ user/.config/systemd/user/openclaw-gateway.service:18:EnvironmentNO_PROXYlocalhost,127.0.0.0/8,::1 user/.config/systemd/user/openclaw-gateway.service:19:EnvironmentALL_PROXYsocks://10.0.0.9:7897/ user/.config/systemd/user/openclaw-gateway.service:20:Environmenthttp_proxyhttp://10.0.0.9:7897/ user/.config/systemd/user/openclaw-gateway.service:21:Environmenthttps_proxyhttp://10.0.0.9:7897/ user/.config/systemd/user/openclaw-gateway.service:22:Environmentno_proxylocalhost,127.0.0.0/8,::1 user/.config/systemd/user/openclaw-gateway.service:23:Environmentall_proxysocks://10.0.0.9:7897/ user/.config/systemd/user/openclaw-gateway.service.bak:16:EnvironmentHTTP_PROXYhttp://10.0.0.9:7897/ user/.config/systemd/user/openclaw-gateway.service.bak:17:EnvironmentHTTPS_PROXYhttp://10.0.0.9:7897/ user/.config/systemd/user/openclaw-gateway.service.bak:18:EnvironmentNO_PROXYlocalhost,127.0.0.0/8,::1 user/.config/systemd/user/openclaw-gateway.service.bak:19:EnvironmentALL_PROXYsocks://10.0.0.9:7897/ user/.config/systemd/user/openclaw-gateway.service.bak:20:Environmenthttp_proxyhttp://10.0.0.9:7897/ user/.config/systemd/user/openclaw-gateway.service.bak:21:Environmenthttps_proxyhttp://10.0.0.9:7897/ user/.config/systemd/user/openclaw-gateway.service.bak:22:Environmentno_proxylocalhost,127.0.0.0/8,::1 user/.config/systemd/user/openclaw-gateway.service.bak:23:Environmentall_proxysocks://10.0.0.9:7897/ /usr/lib/systemd/user/gnome-sessiongnome-login.target.d/session.conf:11:Wantsorg.gnome.SettingsDaemon.ScreensaverProxy.target /usr/lib/systemd/user/org.gnome.SettingsDaemon.ScreensaverProxy.service:11:Requisiteorg.gnome.SettingsDaemon.ScreensaverProxy.target /usr/lib/systemd/user/org.gnome.SettingsDaemon.ScreensaverProxy.service:12:PartOforg.gnome.SettingsDaemon.ScreensaverProxy.target /usr/lib/systemd/user/org.gnome.SettingsDaemon.ScreensaverProxy.service:13:Beforeorg.gnome.SettingsDaemon.ScreensaverProxy.target /usr/lib/systemd/user/org.gnome.SettingsDaemon.ScreensaverProxy.service:20:ExecStart/usr/libexec/gsd-screensaver-proxy /usr/lib/systemd/user/org.gnome.SettingsDaemon.ScreensaverProxy.service:22:BusNameorg.gnome.SettingsDaemon.ScreensaverProxy /usr/lib/systemd/user/dirmngr.service:7:ExecStart/usr/bin/dirmngr --supervised --honor-http-proxy /usr/lib/systemd/user/tracker-miner-fs-control-3.service:2:DescriptionTracker Filesystem Indexing Proxy /usr/lib/systemd/user/gnome-sessionubuntu.target.d/ubuntu.session.conf:12:Wantsorg.gnome.SettingsDaemon.ScreensaverProxy.target /usr/lib/systemd/user/org.gnome.SettingsDaemon.ScreensaverProxy.target:6:Wantsorg.gnome.SettingsDaemon.ScreensaverProxy.service /usr/lib/systemd/user/gnome-sessiongnome-initial-setup.target.d/session.conf:12:Wantsorg.gnome.SettingsDaemon.ScreensaverProxy.target /usr/lib/systemd/user/glib-pacrunner.service:2:DescriptionGLib proxy auto-configuration service找到了根因就是这个~/.config/systemd/user/openclaw-gateway.service里面第 16–23 行把代理写死了所以每次 systemd user 启动openclaw-gateway都会带上HTTP_PROXYhttp://10.0.0.9:7897/HTTPS_PROXYhttp://10.0.0.9:7897/ALL_PROXYsocks://10.0.0.9:7897/这也是为什么你当前 shell 没有 proxysystemctl --user show-environment也没有 proxy但openclaw进程里始终有 proxy因为这是unit 级别的 Environment不是全局环境。3. 处理办法3.1 直接编辑这个文件vim ~/.config/systemd/user/openclaw-gateway.service把这几行删掉或注释掉EnvironmentHTTP_PROXYhttp://10.0.0.9:7897/ EnvironmentHTTPS_PROXYhttp://10.0.0.9:7897/ EnvironmentNO_PROXYlocalhost,127.0.0.0/8,::1 EnvironmentALL_PROXYsocks://10.0.0.9:7897/ Environmenthttp_proxyhttp://10.0.0.9:7897/ Environmenthttps_proxyhttp://10.0.0.9:7897/ Environmentno_proxylocalhost,127.0.0.0/8,::1 Environmentall_proxysocks://10.0.0.9:7897/建议保留一个不走代理的NO_PROXY也行但不是必须。最简单就是先全删。然后执行systemctl --user daemon-reload systemctl --user restart openclaw-gateway再验证ps -ef | grep -i openclaw cat /proc/$(pgrep -f openclaw-gateway | head -n1)/environ | tr \0 \n | grep -i proxy avahi 926 1 0 18:18 ? 00:00:03 avahi-daemon: running [openclaw.local] user 124345 1249 0 23:27 ? 00:00:00 openclaw user 124352 124345 20 23:27 ? 00:00:08 openclaw-gateway user 124621 2938 0 23:28 pts/1 00:00:00 grep --colorauto -i openclaw正常情况下这里应该就没有任何 proxy了或者只剩你手动保留的NO_PROXY。3.2 还要顺手处理一个地方你这里还有一个软链接/副本~/.config/systemd/user/default.target.wants/openclaw-gateway.service通常它只是指向上面的 service 文件。你可以确认一下openclaw:~$ ls -ahl user/.config/systemd/user/default.target.wants/openclaw-gateway.service lrwxrwxrwx 1 user user 57 3月 14 00:21 user/.config/systemd/user/default.target.wants/openclaw-gateway.service - user/.config/systemd/user/openclaw-gateway.service如果是符号链接不用单独改。如果不是链接而是一份独立副本那也要一起改不然可能混淆。3.3 备份文件不用管~/.config/systemd/user/openclaw-gateway.service.bak只是备份不会被 systemd 直接加载除非你自己拿它恢复了。可直接删除。3.4 重启网关openclaw gateway restart

相关新闻