OpenClaw Crashing: Fix Memory & Restart Issues

ErrorsPerformance

OpenClaw Crashing: Fix Memory & Restart Issues

Diagnose and fix OOM kills, gateway restart loops, and memory leaks in long-running instances.

7 min readLast updated Feb 18, 2026
Stuck?Check the troubleshooting index or ask in Discord.

Overview

This guide covers diagnosing and fixing gateway restart issues and memory problems in OpenClaw. If your gateway keeps restarting or using too much memory, this guide will help.

Diagnosing Restarts

Start by checking the gateway status and logs:

bash
# Check gateway status
openclaw gateway status

# View recent logs
openclaw logs --lines 100

# Follow logs in real-time
openclaw logs --follow

Look for patterns:

  • Repeated crashes at specific times
  • Errors before shutdown
  • Memory warnings
  • Port already in use errors

Out of Memory (OOM)

If the gateway is being killed by the system (OOM killer), you need to reduce memory usage:

1. Reduce Docker memory limit

yaml
deploy:
  resources:
    limits:
      memory: 2G  # Reduce from 4G

2. Reduce context window

yaml
agents:
  defaults:
    model:
      contextTokens: 50000  # Reduce from 200000

3. Enable memory compaction

yaml
agents:
  defaults:
    compaction:
      mode: "safeguard"
      reserveTokensFloor: 24000

4. Check memory usage

bash
# Docker
docker stats

# System
free -h
htop

Port Conflicts

If you see "port already in use" errors:

1

Find what's using the port

bash
# For port 3000
lsof -i :3000

# For port 18789
lsof -i :18789
2

Stop the conflicting process

bash
# Kill by PID
kill -9 <PID>

# Or stop the service
sudo systemctl stop openclaw
3

Restart gateway

bash
openclaw gateway restart
Prevent port conflicts
Make sure you don't have multiple OpenClaw instances running. Check with ps aux | grep openclaw

Service Issues

If OpenClaw is installed as a system service:

Check service status

bash
sudo systemctl status openclaw-gateway
sudo journalctl -u openclaw-gateway -n 50

Reinstall service

bash
openclaw gateway install --force
openclaw gateway restart

Check config location

Service config is at ~/.openclaw/openclaw.json for your user, or ~openclaw/.openclaw/openclaw.json for the system service.

Prevention & Monitoring

Set up monitoring to catch issues early:

1. Health checks

bash
# Check health
curl http://localhost:3000/api/health

2. Add cron monitoring

bash
# Check every 5 minutes
*/5 * * * * curl -sf http://localhost:3000/api/health || systemctl restart openclaw-gateway

3. Set up logging

Ensure logging is enabled to diagnose issues after they happen:

yaml
logging:
  level: info  # or debug for more detail

4. Use the doctor command

bash
openclaw doctor

This checks for common issues and misconfigurations.