Skip to content

Troubleshooting - Common Issues and Solutions

What You'll Learn

After completing this course, you will be able to:

  • Use the doctor command to diagnose and fix issues
  • Analyze logs to identify root causes of problems
  • Handle common configuration errors
  • Master debugging techniques and tools

Core Approach

Troubleshooting is a critical system administration skill. OpenClaw provides various diagnostic tools and methods to help you quickly locate and resolve issues.

┌─────────────────────────────────────────────────────────────┐
│                  Troubleshooting Process                     │
├─────────────────────────────────────────────────────────────┤
│                                                              │
│   Identify Problem                                          │
│       │                                                      │
│       ▼                                                      │
│   ┌─────────────────────────────────────────────────────┐   │
│   │  1. Run doctor diagnostics                           │   │
│   │     openclaw doctor                                  │   │
│   └─────────────────────────────────────────────────────┘   │
│       │                                                      │
│       ▼                                                      │
│   ┌─────────────────────────────────────────────────────┐   │
│   │  2. Check status                                     │   │
│   │     openclaw status                                  │   │
│   │     openclaw channels status                         │   │
│   └─────────────────────────────────────────────────────┘   │
│       │                                                      │
│       ▼                                                      │
│   ┌─────────────────────────────────────────────────────┐   │
│   │  3. View logs                                        │   │
│   │     openclaw logs                                    │   │
│   │     openclaw logs --follow                           │   │
│   └─────────────────────────────────────────────────────┘   │
│       │                                                      │
│       ▼                                                      │
│   ┌─────────────────────────────────────────────────────┐   │
│   │  4. Targeted investigation                           │   │
│   │     - Config issues → config validate                │   │
│   │     - Network issues → ping/curl tests               │   │
│   │     - Permission issues → ls -la / check permissions │   │
│   └─────────────────────────────────────────────────────┘   │
│       │                                                      │
│       ▼                                                      │
│   Resolve Issue / Seek Help                                 │
│                                                              │
└─────────────────────────────────────────────────────────────┘

Diagnostic Tools

Doctor Command

openclaw doctor is a comprehensive diagnostic tool that can detect and automatically fix many common issues.

bash
# Run full diagnostics
openclaw doctor

# Non-interactive mode
openclaw doctor --non-interactive

# Generate diagnosis report
openclaw doctor --report > diagnosis.txt

Status Check Commands

bash
# Check Gateway status
openclaw status

# Check channel status
openclaw channels status

# Validate configuration
openclaw config validate

# Test model connectivity
openclaw models test

Log Viewing

bash
# View Gateway logs
openclaw logs gateway

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

# View specific channel logs
openclaw logs --channel whatsapp

# View last 100 lines
openclaw logs --lines 100

Common Issue Solutions

1. Gateway Won't Start

Symptoms

Error: Gateway failed to start
Port 18789 is already in use

Troubleshooting Steps

bash
# Check port usage
lsof -i :18789
ss -tlnp | grep 18789

# Kill process using the port
kill -9 $(lsof -t -i:18789)

# Or use a different port
openclaw gateway run --port 18790

Possible Causes and Solutions

CauseSymptomSolution
Port occupiedPort already in useKill the process or change port
Config errorInvalid configRun openclaw doctor to fix
Insufficient permissionsPermission deniedCheck file permissions, try sudo
Missing dependenciesModule not foundReinstall npm install -g openclaw

2. AI Not Responding

Symptoms
AI doesn't reply after sending a message.

Troubleshooting Steps

bash
# 1. Check if Gateway is running
openclaw status

# 2. Check model configuration
openclaw models list
openclaw models test anthropic/claude-3-5-sonnet

# 3. Check API Key
openclaw config get models.providers.anthropic.apiKey

# 4. View detailed logs
openclaw logs --follow

Common Causes

CauseCheck MethodSolution
Gateway not runningopenclaw statusStart Gateway
Invalid API KeyCheck log errorsUpdate API Key
Model unavailableopenclaw models testCheck model ID or switch to fallback
Network issuescurl api.anthropic.comCheck network connection

3. Channel Connection Failed

Symptoms
WhatsApp/Telegram and other channels show as disconnected.

WhatsApp-Specific Issues

bash
# Check WhatsApp status
openclaw channels status whatsapp

# Re-pair
openclaw whatsapp logout
openclaw whatsapp login

# Check Baileys storage
ls -la ~/.openclaw/whatsapp/

Telegram-Specific Issues

bash
# Verify Bot Token
curl https://api.telegram.org/bot<TOKEN>/getMe

# Check WebHook status
curl https://api.telegram.org/bot<TOKEN>/getWebhookInfo

# Reset WebHook
curl -F "url=" https://api.telegram.org/bot<TOKEN>/setWebhook

4. Configuration Errors

Symptoms
Invalid config at ~/.openclaw/openclaw.json

Fix Methods

bash
# Auto-fix configuration
openclaw doctor

# Or reset configuration
mv ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.bak
openclaw setup

# Manually validate configuration
openclaw config validate

Common Configuration Errors

Error TypeExampleFix
JSON syntax errorMissing comma/quotesUse doctor to auto-fix
Invalid value"enabled": "yes"Change to "enabled": true
Path error~ not expandedUse absolute path or ${HOME}
Type errorport: "18789"Change to port: 18789

5. Performance Issues

Symptoms
Slow response, high CPU/memory usage.

Diagnostic Commands

bash
# View resource usage
top -p $(pgrep -d',' openclaw)
htop

# View Gateway stats
openclaw status --stats

# Check active sessions
openclaw sessions list

# Clean old sessions
openclaw sessions prune --older-than 7d

Optimization Tips

IssueOptimization Method
High memory usageReduce maxConcurrentRuns, clean old sessions
Slow responseUse faster model, enable caching
High CPU usageLimit concurrency, use headless browser
High disk usageConfigure log rotation, clean media files

Using Doctor for Auto-Fix

Doctor Diagnostic Modules

src/commands/doctor.ts implements comprehensive diagnostics:

ModuleFunctionAuto-Fix
Config checkValidate openclaw.json
Auth checkValidate API Key and Token
Legacy state migrationMigrate old version data
Sandbox checkValidate Docker sandbox
Gateway serviceCheck service configuration
Platform-specificmacOS LaunchAgent etc.

Running Diagnostics Example

bash
$ openclaw doctor

 OpenClaw doctor

├─ Gateway
  ├─ Config valid
  ├─ ⚠️  Token auth recommended
  └─ Service configured

├─ Channels
  ├─ WhatsApp connected
  ├─ Telegram connected
  └─ ⚠️  Discord not configured

├─ Models
  ├─ Anthropic API reachable
  └─ Default model available

└─ Fixes Applied
   └─ Generated gateway token automatically

Log Analysis Tips

Log Levels

bash
# Set log level
export OPENCLAW_LOG_LEVEL=debug

# Available levels: error, warn, info, debug, trace

Common Log Patterns

# Connection successful
[INFO] gateway: server started on port 18789

# Auth failure
[WARN] auth: invalid token from 192.168.1.100

# Model call
[DEBUG] agent: calling model anthropic/claude-3-5-sonnet
[INFO] agent: response received in 2345ms

# Error
[ERROR] channels.whatsapp: connection lost, reconnecting...

Log Filtering

bash
# View only errors
openclaw logs | grep ERROR

# Follow specific channel
openclaw logs --channel whatsapp --follow

# Filter by time range
openclaw logs --since "2024-02-14 09:00" --until "2024-02-14 10:00"

Getting Help

Command Help

bash
# View command help
openclaw --help
openclaw doctor --help
openclaw config --help

# View subcommand help
openclaw channels --help

Community Support

Reporting Issues

When reporting issues, please include:

  1. OpenClaw version: openclaw --version
  2. Operating system and version
  3. Steps to reproduce the issue
  4. Relevant log snippets
  5. Solutions already attempted

Lesson Summary

In this course, you learned:

  • ✅ Systematic troubleshooting process
  • ✅ Using doctor command for auto-diagnosis and fixing
  • ✅ Diagnosis and solutions for common issues
  • ✅ Log analysis techniques
  • ✅ Optimization methods for performance issues
  • ✅ Where to get help

Next Lesson Preview

In the next lesson, we'll learn about Security Guide.

You'll learn:

  • Security models and best practices
  • DM pairing mechanism
  • Sandbox execution and access control

Appendix: Source Code Reference

Click to view source locations

Last updated: 2026-02-14

FeatureFile PathLine Numbers
Doctor main commandsrc/commands/doctor.ts65-300
Doctor auth modulesrc/commands/doctor-auth.ts-
Doctor config flowsrc/commands/doctor-config-flow.ts-
Doctor sandbox modulesrc/commands/doctor-sandbox.ts-
Status commandsrc/commands/status.ts-
Gateway health checksrc/commands/doctor-gateway-health.ts-

Diagnostic Types:

  • Config validation
  • Auth health
  • Legacy state migration
  • Sandbox integrity
  • Service configuration
  • Platform-specific checks