Gateway
The Gateway is the heart of OpenClaw—a WebSocket server that acts as the central control plane for all messaging channels, AI agents, and platform apps.What is the Gateway?
The Gateway is a background process that:- Runs a WebSocket server at
ws://127.0.0.1:18789(default) - Manages messaging channels (WhatsApp, Telegram, Discord, etc.)
- Routes messages to appropriate AI agents based on configuration
- Maintains sessions for conversation context
- Provides HTTP endpoints for Control UI and webhooks
- Broadcasts events to connected clients
Gateway Process
Starting the Gateway
Manual Start:Gateway Lock
The Gateway uses a lock file to prevent multiple instances:Process Modes
The Gateway can run in different modes:- Local: Binds to 127.0.0.1 (default, most secure)
- LAN: Binds to 0.0.0.0 (all interfaces)
- Tailscale: Auto-configures Tailscale Serve/Funnel
- Custom: Specific IP address
WebSocket Server
The Gateway’s WebSocket server provides real-time communication between channels, agents, and clients.Connection
Connect to the Gateway:Authentication
The Gateway supports multiple auth modes: Token Authentication:Protocol Methods
The Gateway supports these JSON-RPC methods:agent
Send a message to the agent:sessions.list
List all active sessions:sessions.get
Get session details:channels.status
Get channel status:gateway.info
Get Gateway information:Event Streaming
The Gateway pushes events to connected clients: Agent Events:agent.text: Streaming text responseagent.thinking: Extended thinking outputagent.tool.start: Tool invocation startedagent.tool.result: Tool execution resultagent.done: Message complete
presence: Channel online/offline statustyping: Typing indicatorsmessage: Inbound message
session.created: New sessionsession.updated: Session metadata changedsession.pruned: Session history compacted
HTTP Server
The Gateway also runs an HTTP server for web access and webhooks.Control UI
Access the Control UI athttp://127.0.0.1:18789/:
- Dashboard: Gateway status and metrics
- Sessions: View and manage sessions
- Channels: Channel status and configuration
- WebChat: Browser-based chat interface
- Logs: Real-time log streaming
- Configuration: Edit config via UI
REST Endpoints
GET /health
Health check endpoint:POST /webhook
Webhook endpoint for external triggers:Configuration
Basic Configuration
Remote Access
LAN Access:Tailscale Serve/Funnel requires the
tailscale CLI to be installed and authenticated.TLS Configuration
Discovery Configuration
mDNS/Bonjour:off: Disable mDNS entirelyminimal: Advertise Gateway without sensitive infofull: Include CLI path and SSH port in TXT records
Management
Status
Check Gateway status:Logs
View Gateway logs:- Daemon logs:
~/.openclaw/logs/gateway.log - Console output: stderr when running manually
Restart
Restart the Gateway:Diagnostics
Run Gateway diagnostics:- Configuration validity
- Port availability
- File permissions
- Channel credentials
- Session integrity
- Migration status
Performance
Connection Limits
- Channels: 10-20 concurrent
- Platform apps: 5-10
- CLI clients: Unlimited
- WebSocket connections: Hundreds
Memory Usage
Typical memory footprint:- Base: 100-200 MB
- +10-50 MB per channel
- +1-5 MB per active session
CPU Usage
- Idle: less than 1%
- Active messaging: 5-15%
- Peak (tool execution): 30-60%
Security
Default Security
- Binds to localhost by default
- No authentication required for localhost
- DM pairing for unknown senders
- Allowlists for channel access
Production Security
See the security guide for detailed recommendations.
Troubleshooting
Gateway won't start
Gateway won't start
Check for:
- Port conflicts:
lsof -i :18789orss -ltnp | grep 18789 - Stale lock file:
rm ~/.openclaw/.gateway.lock - Config errors:
openclaw config validate - Permission issues: Check
~/.openclaw/permissions
Can't connect to Gateway
Can't connect to Gateway
Verify:
- Gateway is running:
openclaw gateway status - Correct port: Check
gateway.portin config - Firewall: Ensure port is open
- Authentication: Use correct token/password
High memory usage
High memory usage
Common causes:
- Too many active sessions: Prune old sessions
- Large message history: Enable auto-compaction
- Memory leak: Restart Gateway and file a bug report
Channels disconnecting
Channels disconnecting
Check:
- Network connectivity
- Channel credentials validity
- Rate limiting (too many messages)
- Gateway logs for errors
Next Steps
Agents
Learn about AI agent configuration and runtime
Channels
Configure messaging channel integrations
Sessions
Understand session management and storage
Deployment
Deploy Gateway to production environments

