openclaw - 💡(How to fix) Fix Gateway update/restart races launchd KeepAlive respawn, causing port conflict [2 comments, 2 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#78699Fetched 2026-05-07 03:33:39
View on GitHub
Comments
2
Participants
2
Timeline
2
Reactions
2
Timeline (top)
commented ×2

During openclaw update (and gateway restarts triggered by updates), the new gateway process is sometimes already running (respawned by launchd) before the update script's own restart logic executes. This causes the restart attempt to fail with a port conflict on 18789.

Error Message

The update completes but the UI hangs briefly before recovering. The gateway log shows the following sequence:

Root Cause

The plist has KeepAlive: true and ThrottleInterval: 1. When the update process calls launchctl stop, launchd respawns the process within 1 second. The update script's subsequent restart races against this respawn and loses the port.

RAW_BUFFERClick to expand / collapse

Summary

During openclaw update (and gateway restarts triggered by updates), the new gateway process is sometimes already running (respawned by launchd) before the update script's own restart logic executes. This causes the restart attempt to fail with a port conflict on 18789.

Observed behavior

The update completes but the UI hangs briefly before recovering. The gateway log shows the following sequence:

  1. Old process is stopped via launchctl
  2. launchd immediately respawns the process (within ~1 second, per ThrottleInterval: 1 in the plist)
  3. The update script then attempts its own restart, finds port 18789 already occupied
  4. Log message: Gateway already running locally. Stop it (openclaw gateway stop) or use a different port.
  5. Eventually resolves because launchd's KeepAlive keeps the valid new process running

Root cause

The plist has KeepAlive: true and ThrottleInterval: 1. When the update process calls launchctl stop, launchd respawns the process within 1 second. The update script's subsequent restart races against this respawn and loses the port.

Expected behavior

The update/restart process should either:

  • Temporarily unload the launchd job (launchctl unload) during the update cycle, then reload after (launchctl load)
  • Or wait for the port to be free before attempting to bind (port-clear check with timeout)
  • Or detect that the new version is already running on the correct port and skip the restart

Environment

  • macOS (Darwin 25.4.0, arm64)
  • OpenClaw version: 2026.5.6 (also observed on prior version)
  • Service type: LaunchAgent
  • Port: 18789

Reproducibility

Reproducible on every openclaw update run. Self-heals each time but causes a visible hang during the update.

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…

FAQ

Expected behavior

The update/restart process should either:

  • Temporarily unload the launchd job (launchctl unload) during the update cycle, then reload after (launchctl load)
  • Or wait for the port to be free before attempting to bind (port-clear check with timeout)
  • Or detect that the new version is already running on the correct port and skip the restart

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Gateway update/restart races launchd KeepAlive respawn, causing port conflict [2 comments, 2 participants]