openclaw - 💡(How to fix) Fix [Linux/systemd] Gateway 2026.4.5 enters infinite self-fork restart loop on startup [2 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#62028Fetched 2026-04-08 03:10:06
View on GitHub
Comments
2
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
commented ×2closed ×1

OpenClaw 2026.4.5 gateway enters an infinite restart loop on Linux/systemd immediately after startup. The gateway forks a child process ~8 seconds after reaching "ready", the child kills the parent via cleanStaleGatewayProcessesSync(), then the child forks again — infinite loop. No CLI invocation or agent session trigger required; it happens on a clean systemctl --user start.

Root Cause

The restart mechanism in restart-stale-pids-6v9JnhXs.js uses lsof -nP -iTCP:PORT -sTCP:LISTEN to find PIDs on the gateway port, then sends SIGTERM + SIGKILL. The gateway appears to self-fork a replacement process during startup (after "starting channels and sidecars"), and this child kills the parent. Since systemd sees the main PID die, it restarts the service, creating an infinite loop.

This is distinct from but related to:

  • #32348 — gateway restart from agent session causes crash loop
  • #52851 — CLI spawns new gateway instance conflicting with systemd service
  • #46849 — gateway status spawns nested gateway from inside running service

Those issues are triggered by CLI invocations from within the gateway context. This issue requires no external trigger — the gateway self-forks on its own during startup.

Fix Action

Workaround

Downgrade to 2026.3.31 (not yet confirmed, planning to test).

Code Example

[gateway] ready (3 plugins, 0.7s)
[gateway] starting channels and sidecars...
[hooks] loaded 4 internal hook handlers
# ~8 seconds pass, 14s CPU time (100%+ utilization)
systemd: Main process exited, code=killed, status=9/KILL
systemd: Scheduled restart job, restart counter is at 213.
[restart] killing 1 stale gateway process(es) before restart: <PREV_PID>
RAW_BUFFERClick to expand / collapse

Summary

OpenClaw 2026.4.5 gateway enters an infinite restart loop on Linux/systemd immediately after startup. The gateway forks a child process ~8 seconds after reaching "ready", the child kills the parent via cleanStaleGatewayProcessesSync(), then the child forks again — infinite loop. No CLI invocation or agent session trigger required; it happens on a clean systemctl --user start.

Environment

  • OpenClaw: 2026.4.5 (3e72c03)
  • OS: Ubuntu 24.04 LTS (Linux 6.x)
  • Node: v22.22.1
  • RAM: 32GB
  • Gateway: systemd user service, loopback bind
  • Profile: custom (OPENCLAW_STATE_DIR, OPENCLAW_CONFIG_PATH set)
  • Channels: Discord enabled, Slack enabled (socket mode)
  • Cron: 2 jobs (disabled during testing — loop persists without them)

Steps to Reproduce

  1. Upgrade OpenClaw from 2026.3.x to 2026.4.5 via npm i -g openclaw
  2. Start gateway via systemctl --user start openclaw-gateway.service
  3. Gateway reaches "ready" in ~2 seconds
  4. ~8 seconds later, main process receives SIGKILL (exit code 9)
  5. systemd restarts (Restart=always), new process repeats the cycle

Log Pattern (repeats indefinitely)

[gateway] ready (3 plugins, 0.7s)
[gateway] starting channels and sidecars...
[hooks] loaded 4 internal hook handlers
# ~8 seconds pass, 14s CPU time (100%+ utilization)
systemd: Main process exited, code=killed, status=9/KILL
systemd: Scheduled restart job, restart counter is at 213.
[restart] killing 1 stale gateway process(es) before restart: <PREV_PID>

The [restart] log from the child process shows it killing the parent PID. In one instance, the log showed a process killing its own PID.

Root Cause Analysis

The restart mechanism in restart-stale-pids-6v9JnhXs.js uses lsof -nP -iTCP:PORT -sTCP:LISTEN to find PIDs on the gateway port, then sends SIGTERM + SIGKILL. The gateway appears to self-fork a replacement process during startup (after "starting channels and sidecars"), and this child kills the parent. Since systemd sees the main PID die, it restarts the service, creating an infinite loop.

This is distinct from but related to:

  • #32348 — gateway restart from agent session causes crash loop
  • #52851 — CLI spawns new gateway instance conflicting with systemd service
  • #46849 — gateway status spawns nested gateway from inside running service

Those issues are triggered by CLI invocations from within the gateway context. This issue requires no external trigger — the gateway self-forks on its own during startup.

What Does NOT Fix It

  1. Migrating cron jobs to new payload: {kind, text} format (fixed separate cron TypeError)
  2. Disabling all cron jobs (enabled: false)
  3. Updating meta.lastTouchedVersion to 2026.4.5
  4. Updating systemd OPENCLAW_SERVICE_VERSION env var
  5. Setting commands.restart: false
  6. Setting gateway.reload.mode: "off"
  7. Disabling Slack channel
  8. Adding ExitType=cgroup to systemd unit
  9. Changing cron wakeMode to next-heartbeat
  10. Reinstalling service via openclaw gateway install --force

Key Observations

  • A second gateway instance on the same machine (different profile/port) that was started before the upgrade is stable — it's running the old pre-2026.4.5 binary from memory
  • A third instance on macOS/launchd running 2026.4.5 is completely stable — this appears to be Linux/systemd specific
  • 14s CPU in 8s wall time = the forked child is burning 100%+ CPU before killing the parent

Expected Behavior

Gateway should start and remain running without self-forking under systemd management.

Workaround

Downgrade to 2026.3.31 (not yet confirmed, planning to test).

extent analysis

TL;DR

The most likely fix for the infinite restart loop issue in OpenClaw 2026.4.5 on Linux/systemd is to identify and address the self-forking mechanism in the gateway startup process.

Guidance

  1. Investigate the restart-stale-pids-6v9JnhXs.js script: Review the script's logic for finding and killing stale gateway processes to understand why it's causing the parent process to be killed.
  2. Verify the gateway's self-forking behavior: Confirm that the gateway is indeed self-forking during startup and identify the conditions under which this occurs.
  3. Check for resource utilization issues: Investigate why the forked child process is burning 100%+ CPU before killing the parent, as this may be contributing to the restart loop.
  4. Test the downgrade to 2026.3.31: Verify if downgrading to the previous version resolves the issue, as suggested in the workaround.
  5. Explore Linux/systemd specific configurations: Since the issue appears to be Linux/systemd specific, investigate if there are any configuration options or environment variables that can be adjusted to prevent the self-forking behavior.

Example

No code snippet is provided as the issue is more related to the overall system behavior and configuration rather than a specific code block.

Notes

The issue seems to be specific to the combination of OpenClaw 2026.4.5 and Linux/systemd, and the provided workaround of downgrading to 2026.3.31 may not be a long-term solution. Further investigation is needed to identify the root cause and develop a more permanent fix.

Recommendation

Apply the workaround by downgrading to 2026.3.31, as it may provide a temporary solution to the infinite restart loop issue, allowing for further investigation and development of a more permanent fix.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING