Persistent local TCP relay for ZCode to fix zai_oauth_required / ETIMEDOUT login failures described in zai-org/feedback#116.
ZCode's bundled Node/undici uses Happy Eyeballs (autoSelectFamily) with a 250ms attempt budget. If IPv6 is dead and IPv4 RTT to api.z.ai is >250ms, connections time out before the TCP handshake finishes.
- Bind a relay on
127.0.0.2:443(local connect ≪ 250ms). - Map
api.z.ai→127.0.0.2in/etc/hosts. - Forward raw TCP to upstream IPv4 for
api.z.ai. - Persist via LaunchDaemon (macOS) or systemd (Linux).
Requires root (port 443 + system service + hosts):
sudo bash ./install.sh
./status.shThen fully quit and reopen ZCode, and Connect to Z.ai.
sudo bash ./uninstall.sh| Path | Role |
|---|---|
bridge.js |
TCP relay |
install.sh / uninstall.sh / status.sh |
OS-detecting helpers |
systemd/zcode-bridge.service |
Linux unit template (install rewrites ExecStart with detected node) |
com.zai.zcode-bridge.plist |
Example macOS plist (install regenerates with detected node) |
| macOS | Linux | |
|---|---|---|
| Script | /Library/Application Support/zcode-bridge/bridge.js |
/usr/local/lib/zcode-bridge/bridge.js |
| Service | /Library/LaunchDaemons/com.zai.zcode-bridge.plist |
/etc/systemd/system/zcode-bridge.service |
| Logs | /var/log/zcode-bridge.log |
journalctl -u zcode-bridge |
- macOS: plist
RunAtLoad+KeepAlive - Linux:
systemctl enable→WantedBy=multi-user.target