Telegram Connection Failed - WebSocket Error 1006
Fix Telegram Connection Failed WebSocket Error 1006 in OpenClaw when the channel disconnects or fails to reconnect. Check the WebSocket drop, bot token, gateway session, and connection setup.
What Is WebSocket Error 1006?
WebSocket error 1006 means the connection between your OpenClaw instance and Telegram was closed abnormally. The connection dropped without a proper close handshake - something interrupted it.
This is not an OpenClaw bug. It is a network-level event that can happen for several reasons. The fix depends on what caused the drop.
Quick Diagnosis
Run these checks in order. Most issues are caught by the first three:
# 1. Check if gateway is running
openclaw gateway status
# 2. Check gateway health
openclaw gateway status --deep
# 3. Test your Telegram bot token
curl https://api.telegram.org/bot<YOUR_TOKEN>/getMeIf the gateway is down, start it. If the token test fails, your token is invalid. If both are fine, read on for network and configuration issues.
Common Causes and Fixes
1. Another Instance Using the Same Bot Token
This is the most common cause. Telegram only allows one active connection per bot token. If you have OpenClaw running on two servers, two Docker containers, or a local machine and a VPS - both using the same token - they will fight for the connection. One stays connected, the other gets error 1006.
- Stop all other OpenClaw instances using this token
- If you are migrating between servers, shut down the old one first
- If you need multiple bots, create a separate bot token via @BotFather for each instance
- Check for forgotten test instances:
docker ps -aon all your machines
2. Invalid or Revoked Bot Token
If the token is wrong, expired, or revoked through BotFather, the WebSocket connection will fail immediately or drop after the first attempt.
curl https://api.telegram.org/bot<YOUR_TOKEN>/getMeIf it returns {"ok":true} with your bot info, the token is valid. If it returns 401 Unauthorized, the token is bad.
- Open Telegram and message @BotFather
- Send
/mybots→ select your bot → API Token - If the token looks wrong, send
/revokeand generate a new one - Update the new token in your OpenClaw configuration
- Restart the gateway:
openclaw gateway restart
3. Network or DNS Issues
Your server cannot reach Telegram's API servers. This happens with unstable VPS connections, DNS resolution failures, or network-level blocks.
# Test connectivity to Telegram
curl -I https://api.telegram.org
ping api.telegram.org
# Check DNS resolution
nslookup api.telegram.org- If DNS fails: try setting DNS to
1.1.1.1or8.8.8.8 - If curl times out: your server or ISP may be blocking Telegram. Some countries block Telegram API
- If using a VPS: check if the hosting provider restricts outbound connections
- Try from a different server or region
4. Reverse Proxy Killing WebSocket Connections
If you run OpenClaw behind Nginx, Caddy, or another reverse proxy, the proxy may be closing long-lived WebSocket connections after a timeout (usually 60 seconds).
location / {
proxy_pass http://localhost:YOUR_PORT;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
}The key settings are proxy_read_timeout and the WebSocket upgrade headers. Without them, Nginx closes the connection after 60 seconds of inactivity.
5. Server Out of Memory or Resources
If your server runs out of RAM, the OS kills processes - including OpenClaw. The Telegram connection drops instantly with error 1006.
# Check memory
free -h
# Check if OOM killer was involved
dmesg | grep -i "oom|killed"
# Check disk space
df -h- Upgrade your VPS to more RAM (4GB minimum recommended)
- Reduce browser automation usage - it consumes the most memory
- Add swap space as a safety buffer
- Clean old logs and temp files if disk is full
6. Gateway Not Auto-Restarting After Crash
If OpenClaw crashes and does not restart automatically, the Telegram connection stays dead until you manually intervene.
- Docker: Add
restart: alwaysto your docker-compose.yml - systemd: Set
Restart=alwaysin your service file - pm2: Use
pm2 start openclaw --watch - See the uptime and reliability guide for detailed auto-restart setup
Step-by-Step Reconnection Guide
If your Telegram bot is disconnected, follow these steps in order:
- Stop all instances - make sure only one OpenClaw instance is running with this bot token
- Verify your token - test with
curl https://api.telegram.org/bot<TOKEN>/getMe - Restart the gateway - run
openclaw gateway restart - Check logs - look for connection errors in the first 30 seconds after restart
- Wait 60 seconds - Telegram sometimes takes a minute to accept a new connection after the old one drops
- Test the bot - send a message to your bot on Telegram and check for a response
- If still failing - generate a new token via @BotFather and update your config
For the full Telegram setup process, see the OpenClaw on Telegram guide.
How to Prevent Telegram Disconnections
- Use one token per instance - never share bot tokens between deployments
- Set up auto-restart - Docker restart policy or systemd service
- Monitor gateway health - use
openclaw gateway probein a cron job to detect failures early - Keep your server stable - enough RAM, disk space, and reliable network
- Configure your reverse proxy - extend WebSocket timeouts if using Nginx
- Update OpenClaw - newer versions have better reconnection handling. See the update guide.
Skip the Server Troubleshooting
Most Telegram connection issues happen because of self-hosting complexity - wrong proxy config, memory limits, missing restart policies, and network problems on cheap VPS providers.
Managed hosting on Ampere.sh handles all of this. The gateway auto-restarts, WebSocket connections are managed, Telegram reconnects automatically, and if something breaks, it recovers without you opening a terminal.
Similar Issues on Other Channels
WebSocket and connection issues are not limited to Telegram. If you are having problems with other channels, check these guides: WhatsApp, Discord, Slack. For general troubleshooting, see Bot Not Responding - OpenClaw Help.
Frequently Asked Questions
What does WebSocket error 1006 mean in OpenClaw?
Why does my OpenClaw Telegram bot keep disconnecting?
Can two OpenClaw instances use the same Telegram bot token?
How do I fix Telegram connection on OpenClaw?
Does Ampere.sh fix Telegram connection issues?
How do I create a new Telegram bot token?
Why does error 1006 happen after a server restart?
How do I check if my Telegram bot token is valid?
Also Read
Stop debugging connection errors
Managed hosting handles Telegram reconnection, gateway restarts, and monitoring automatically. 7-day free trial on Ampere.sh.
Start 7-Day Free Trial →

