问题描述
bash
Network error: [TypeError: fetch failed] { [cause]: ConnectTimeoutError:
Connect Timeout Error (attempted address: 10.0.0.9:7897, timeout: 10000ms)
问题排查
1. env环境变量
bash
env | grep -i proxy
返回是空,即不是这个问题导致;
2. 核心判断
先跑如下命令:
bash
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),然后:
bash
cat /proc/9249/environ | tr '\0' '\n' | grep -i proxy
HTTP_PROXY=http://10.0.0.9:7897/
HTTPS_PROXY=http://10.0.0.9:7897/
NO_PROXY=localhost,127.0.0.0/8,::1
ALL_PROXY=socks://10.0.0.9:7897/
http_proxy=http://10.0.0.9:7897/
https_proxy=http://10.0.0.9:7897/
no_proxy=localhost,127.0.0.0/8,::1
all_proxy=socks://10.0.0.9:7897/
根因确认:
openclaw 启动时带了代理环境变量
执行pkill:
bash
@openclaw:~$ 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 --color=auto -i openclaw
@openclaw:~$ cat /proc/5642/environ | tr '\0' '\n' | grep -i proxy
HTTP_PROXY=http://10.0.0.9:7897/
HTTPS_PROXY=http://10.0.0.9:7897/ NO_PROXY=localhost,127.0.0.0/8,::1
ALL_PROXY=socks://10.0.0.9:7897/
http_proxy=http://10.0.0.9:7897/
https_proxy=http://10.0.0.9:7897/ no_proxy=localhost,127.0.0.0/8,::1
all_proxy=socks://10.0.0.9:7897/
这说明:
❗ 不是旧进程遗留
❗ 不是临时 shell export
✅ 是"启动链条里固定注入的环境变量"
**核心推断:**结合你所有信息,可以明确:
👉 openclaw 是由 某个父进程(PID 1249)启动的
现在最关键一步(直接定位元凶):
运行:
bash
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 环境里被注入的
再执行如下操作:
bash
@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,而且带了自动重启。
先跑这几条:
bash
@openclaw:~$ systemctl --user list-units --type=service | 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
然后再运行下面指令:
bash
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:Environment=HTTP_PROXY=http://10.0.0.9:7897/
user/.config/systemd/user/default.target.wants/openclaw-gateway.service:17:Environment=HTTPS_PROXY=http://10.0.0.9:7897/
user/.config/systemd/user/default.target.wants/openclaw-gateway.service:18:Environment=NO_PROXY=localhost,127.0.0.0/8,::1
user/.config/systemd/user/default.target.wants/openclaw-gateway.service:19:Environment=ALL_PROXY=socks://10.0.0.9:7897/
user/.config/systemd/user/default.target.wants/openclaw-gateway.service:20:Environment=http_proxy=http://10.0.0.9:7897/
user/.config/systemd/user/default.target.wants/openclaw-gateway.service:21:Environment=https_proxy=http://10.0.0.9:7897/
user/.config/systemd/user/default.target.wants/openclaw-gateway.service:22:Environment=no_proxy=localhost,127.0.0.0/8,::1
user/.config/systemd/user/default.target.wants/openclaw-gateway.service:23:Environment=all_proxy=socks://10.0.0.9:7897/
user/.config/systemd/user/openclaw-gateway.service:16:Environment=HTTP_PROXY=http://10.0.0.9:7897/
user/.config/systemd/user/openclaw-gateway.service:17:Environment=HTTPS_PROXY=http://10.0.0.9:7897/
user/.config/systemd/user/openclaw-gateway.service:18:Environment=NO_PROXY=localhost,127.0.0.0/8,::1
user/.config/systemd/user/openclaw-gateway.service:19:Environment=ALL_PROXY=socks://10.0.0.9:7897/
user/.config/systemd/user/openclaw-gateway.service:20:Environment=http_proxy=http://10.0.0.9:7897/
user/.config/systemd/user/openclaw-gateway.service:21:Environment=https_proxy=http://10.0.0.9:7897/
user/.config/systemd/user/openclaw-gateway.service:22:Environment=no_proxy=localhost,127.0.0.0/8,::1
user/.config/systemd/user/openclaw-gateway.service:23:Environment=all_proxy=socks://10.0.0.9:7897/
user/.config/systemd/user/openclaw-gateway.service.bak:16:Environment=HTTP_PROXY=http://10.0.0.9:7897/
user/.config/systemd/user/openclaw-gateway.service.bak:17:Environment=HTTPS_PROXY=http://10.0.0.9:7897/
user/.config/systemd/user/openclaw-gateway.service.bak:18:Environment=NO_PROXY=localhost,127.0.0.0/8,::1
user/.config/systemd/user/openclaw-gateway.service.bak:19:Environment=ALL_PROXY=socks://10.0.0.9:7897/
user/.config/systemd/user/openclaw-gateway.service.bak:20:Environment=http_proxy=http://10.0.0.9:7897/
user/.config/systemd/user/openclaw-gateway.service.bak:21:Environment=https_proxy=http://10.0.0.9:7897/
user/.config/systemd/user/openclaw-gateway.service.bak:22:Environment=no_proxy=localhost,127.0.0.0/8,::1
user/.config/systemd/user/openclaw-gateway.service.bak:23:Environment=all_proxy=socks://10.0.0.9:7897/
/usr/lib/systemd/user/gnome-session@gnome-login.target.d/session.conf:11:Wants=org.gnome.SettingsDaemon.ScreensaverProxy.target
/usr/lib/systemd/user/org.gnome.SettingsDaemon.ScreensaverProxy.service:11:Requisite=org.gnome.SettingsDaemon.ScreensaverProxy.target
/usr/lib/systemd/user/org.gnome.SettingsDaemon.ScreensaverProxy.service:12:PartOf=org.gnome.SettingsDaemon.ScreensaverProxy.target
/usr/lib/systemd/user/org.gnome.SettingsDaemon.ScreensaverProxy.service:13:Before=org.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:BusName=org.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:Description=Tracker Filesystem Indexing Proxy
/usr/lib/systemd/user/gnome-session@ubuntu.target.d/ubuntu.session.conf:12:Wants=org.gnome.SettingsDaemon.ScreensaverProxy.target
/usr/lib/systemd/user/org.gnome.SettingsDaemon.ScreensaverProxy.target:6:Wants=org.gnome.SettingsDaemon.ScreensaverProxy.service
/usr/lib/systemd/user/gnome-session@gnome-initial-setup.target.d/session.conf:12:Wants=org.gnome.SettingsDaemon.ScreensaverProxy.target
/usr/lib/systemd/user/glib-pacrunner.service:2:Description=GLib proxy auto-configuration service
找到了,根因就是这个:
~/.config/systemd/user/openclaw-gateway.service
里面第 16--23 行把代理写死 了,所以每次 systemd user 启动 openclaw-gateway,都会带上:
HTTP_PROXY=http://10.0.0.9:7897/HTTPS_PROXY=http://10.0.0.9:7897/ALL_PROXY=socks://10.0.0.9:7897/
这也是为什么:
- 你当前 shell 没有 proxy
systemctl --user show-environment也没有 proxy- 但
openclaw进程里始终有 proxy
因为这是 unit 级别的 Environment=,不是全局环境。
3. 处理办法
3.1 直接编辑这个文件
bash
vim ~/.config/systemd/user/openclaw-gateway.service
把这几行删掉或注释掉:
bash
Environment=HTTP_PROXY=http://10.0.0.9:7897/
Environment=HTTPS_PROXY=http://10.0.0.9:7897/
Environment=NO_PROXY=localhost,127.0.0.0/8,::1
Environment=ALL_PROXY=socks://10.0.0.9:7897/
Environment=http_proxy=http://10.0.0.9:7897/
Environment=https_proxy=http://10.0.0.9:7897/
Environment=no_proxy=localhost,127.0.0.0/8,::1
Environment=all_proxy=socks://10.0.0.9:7897/
建议保留一个不走代理的 NO_PROXY 也行,但不是必须。最简单就是先全删。
然后执行:
bash
systemctl --user daemon-reload
systemctl --user restart openclaw-gateway
再验证:
bash
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 --color=auto -i openclaw
正常情况下,这里应该就没有任何 proxy 了,或者只剩你手动保留的 NO_PROXY。
3.2 还要顺手处理一个地方
你这里还有一个软链接/副本:
~/.config/systemd/user/default.target.wants/openclaw-gateway.service
通常它只是指向上面的 service 文件。你可以确认一下:
bash
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 重启网关
bash
openclaw gateway restart