Skip to content

Gateway spawns duplicate orphan process causing port conflict #8069

@RichClarkeAI

Description

@RichClarkeAI

Summary

The gateway service spawns a duplicate openclaw-gateway subprocess that persists after the main service restarts, causing port 18789 conflicts and infinite restart loops.

Environment

  • openclaw version: 2026.2.1
  • OS: Ubuntu (Linux 6.14.0-37-generic)
  • Node.js: 22.x
  • Service manager: systemd (user service)

Steps to Reproduce

  1. Run gateway via systemd user service (clawdbot-gateway.service)
  2. Service runs normally for some time
  3. At some point, an orphan openclaw-gateway process gets spawned
  4. If systemd restarts the service, the orphan holds port 18789
  5. New service instance fails with "Port 18789 is already in use"
  6. Restart loop continues indefinitely

Observed Behavior

Process tree shows duplicate gateway processes:

clawdbot (systemd-managed, pid 821565)
├── clawdbot-gateway (correct child, pid 821573)
└── openclaw-gateway (orphan subprocess, pid 822412)

The orphan is spawned via node:

/usr/bin/node /home/user/.npm-global/lib/node_modules/openclaw/dist/index.js gateway --port 18789

Journal shows the restart loop:

Gateway failed to start: another gateway instance is already listening on ws://127.0.0.1:18789
Port 18789 is already in use.
- pid 640043 rich: openclaw-gateway (127.0.0.1:18789)

The systemd restart counter reached 3334 before manual intervention.

Expected Behavior

  • Only one gateway process should exist at a time
  • Child processes should be properly managed and terminated when parent stops
  • No orphan processes should persist after service restart

Impact

  • Gateway becomes unavailable until manual intervention
  • Health checks pass (orphan responds to HTTP) masking the issue
  • Systemd restart loop wastes CPU cycles
  • Users can't reach their messaging integrations

Workaround

Kill the orphan process manually:

# Find the orphan
ss -tlnp | grep 18789
# Kill it
kill <orphan_pid>
# Restart service
systemctl --user restart clawdbot-gateway

Possible Causes

The orphan may be spawned when:

  1. clawdbot-gateway internally calls the CLI to spawn workers
  2. A subprocess escapes the process group during shutdown
  3. Signal handling doesn't propagate to all children

Related

This may be related to the clawdbot→openclaw rename/migration - the service file references clawdbot binaries but spawns openclaw-gateway subprocesses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions