Fix: OpenClaw in Docker — Connection Refused, Port Mapping, and Network Issues
Running OpenClaw in Docker and getting connection refused? Common issues with port mapping, bind addresses, DNS resolution, and WebSocket upgrades explained with fixes.
When OpenClaw can’t authenticate with your model provider, you’ll see errors like:
Error: 401 Unauthorized - Invalid API keyError: You exceeded your current quotaError: model "gpt-4o" not found or not available for your API keyHere’s how to fix each one.
openclaw statusLook for the model provider section. If it shows “not configured,” set your key:
# OpenAI
openclaw configure --set providers.openai.apiKey='sk-...'
# Anthropic
openclaw configure --set providers.anthropic.apiKey='sk-ant-...'
# Azure OpenAI
openclaw configure --set providers.azure.apiKey='your-key'
openclaw configure --set providers.azure.endpoint='https://your-resource.openai.azure.com'| Provider | Key prefix | Example |
|---|---|---|
| OpenAI | sk- or sk-proj- | sk-proj-abc123... |
| Anthropic | sk-ant- | sk-ant-api03-... |
| Azure OpenAI | (varies) | a1b2c3d4e5f6... |
| GitHub Copilot | (OAuth token) | Configured via openclaw configure |
# Quick test — OpenAI
curl -s https://api.openai.com/v1/models -H "Authorization: Bearer sk-your-key" | head -5
# Quick test — Anthropic
curl -s https://api.anthropic.com/v1/messages -H "x-api-key: sk-ant-your-key" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" -d '{"model":"claude-sonnet-4-20250514","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'If the curl test also fails, regenerate your API key at the provider’s dashboard.
Error: You exceeded your current quota. Please check your plan and billing details.This means either:
OpenClaw handles rate limits automatically with exponential backoff. But if you’re consistently hitting limits:
{
"models": {
"default": "claude-sonnet-4-20250514",
"fallback": "gpt-4o-mini"
}
}Setting a fallback model means if your primary model rate-limits, OpenClaw can fall through to a cheaper/less-limited model.
Set spending limits at the provider level:
Error: model "gpt-4o" not foundPossible causes:
Common model names (as of 2026):
# OpenAI
gpt-4o
gpt-4o-mini
gpt-5-mini
o3-mini
# Anthropic
claude-sonnet-4-20250514
claude-opus-4-20250514
claude-haiku-3-20240307
# GitHub Copilot (via OpenClaw)
github-copilot/gpt-4o
github-copilot/claude-sonnet-4-20250514
github-copilot/claude-opus-4-20250514GitHub Copilot Pro gives you access to GPT-5-mini and Claude models through OpenClaw without separate API keys. This is the most cost-effective way to run OpenClaw if you already have a Copilot subscription.
openclaw configure
# Follow the GitHub OAuth flow when promptedFor the full GPT-5-mini + Copilot Pro setup, see my detailed guide: OpenClaw with GPT-5-mini via Copilot Pro.
For reliability, configure multiple providers and set fallback chains:
{
"providers": {
"anthropic": {
"apiKey": "sk-ant-..."
},
"openai": {
"apiKey": "sk-..."
}
},
"models": {
"default": "claude-sonnet-4-20250514",
"fallback": "gpt-4o-mini"
}
}# Check current configuration (keys are masked)
openclaw status
# Test a specific model
openclaw test-model claude-sonnet-4-20250514
# Check gateway logs for API errors
openclaw gateway logs | grep -i "error\|401\|403\|429"AI & Cloud Advisor with 18+ years experience. Author of 8 technical books, creator of Ansible Pilot, and instructor at CopyPasteLearn Academy. Speaker at KubeCon EU & Red Hat Summit 2026.
Running OpenClaw in Docker and getting connection refused? Common issues with port mapping, bind addresses, DNS resolution, and WebSocket upgrades explained with fixes.
Getting the allowedorigins error when starting your OpenClaw gateway? Here is exactly how to fix it, with step-by-step configuration for local network, VPS, and reverse proxy setups.
The OpenClaw origin not allowed error means your browser URL does not match the gateway's allowed origins list. Here is how to diagnose and fix it in 60 seconds.