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>/getMe

If 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.

How to fix
  • 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 -a on 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.

How to check
curl https://api.telegram.org/bot<YOUR_TOKEN>/getMe

If it returns {"ok":true} with your bot info, the token is valid. If it returns 401 Unauthorized, the token is bad.

How to fix
  • Open Telegram and message @BotFather
  • Send /mybots → select your bot → API Token
  • If the token looks wrong, send /revoke and 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.

How to check
# Test connectivity to Telegram curl -I https://api.telegram.org ping api.telegram.org # Check DNS resolution nslookup api.telegram.org
How to fix
  • If DNS fails: try setting DNS to 1.1.1.1 or 8.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).

Nginx fix - add to your config
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.

How to check
# Check memory free -h # Check if OOM killer was involved dmesg | grep -i "oom|killed" # Check disk space df -h
How to fix
  • 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.

How to fix
  • Docker: Add restart: always to your docker-compose.yml
  • systemd: Set Restart=always in 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:

  1. Stop all instances - make sure only one OpenClaw instance is running with this bot token
  2. Verify your token - test with curl https://api.telegram.org/bot<TOKEN>/getMe
  3. Restart the gateway - run openclaw gateway restart
  4. Check logs - look for connection errors in the first 30 seconds after restart
  5. Wait 60 seconds - Telegram sometimes takes a minute to accept a new connection after the old one drops
  6. Test the bot - send a message to your bot on Telegram and check for a response
  7. 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 probe in 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?
Error 1006 means the WebSocket connection was closed abnormally - it dropped without a proper close handshake. Common causes are network interruption, server timeout, proxy issues, or the Telegram bot token being used by another instance.
Why does my OpenClaw Telegram bot keep disconnecting?
Most common reasons: another instance is using the same bot token, your server has unstable internet, a reverse proxy is timing out WebSocket connections, or the server runs out of memory and kills the process.
Can two OpenClaw instances use the same Telegram bot token?
No. Telegram only allows one active connection per bot token. If another instance connects with the same token, the first one gets kicked off. Use a unique bot token per OpenClaw instance.
How do I fix Telegram connection on OpenClaw?
Check your bot token is valid and unique, verify no other instance uses the same token, check your network and proxy settings, restart the gateway, and monitor logs for specific error messages.
Does Ampere.sh fix Telegram connection issues?
Managed hosting handles reconnection, monitoring, and gateway restarts automatically. Most Telegram issues on Ampere.sh are resolved by reconfiguring the bot token through the dashboard.
How do I create a new Telegram bot token?
Open Telegram, search for @BotFather, send /newbot, follow the prompts to name your bot, and copy the token. Use this new token in your OpenClaw Telegram channel configuration.
Why does error 1006 happen after a server restart?
After a restart, OpenClaw needs to re-establish the WebSocket connection to Telegram. If the gateway does not start automatically or the old connection has not timed out yet, you may see temporary 1006 errors. They usually resolve within 30-60 seconds.
How do I check if my Telegram bot token is valid?
Call the Telegram API directly: curl https://api.telegram.org/bot/getMe - if it returns your bot info, the token is valid. If it returns unauthorized, the token is wrong or revoked.

Also Read

OpenClaw on Telegram: Integrate Your AI Agent with Telegram
Installation

OpenClaw on Telegram: Integrate Your AI Agent with Telegram

·
OpenClaw Bot Not Responding? Fix API Key & Gateway Issues
Guide

OpenClaw Bot Not Responding? Fix API Key & Gateway Issues

·
OpenClaw Uptime and Reliability: Keep Your AI Agent Running 24/7
Guide

OpenClaw Uptime and Reliability: Keep Your AI Agent Running 24/7

·
Sarah Mitchell

Written by

Sarah Mitchell

Integration Specialist Writer

Sarah is an API integration specialist with deep expertise in connecting AI agents with messaging platforms and productivity tools. She has architected integrations for Discord, Telegram, WhatsApp, Slack, and Notion, serving over 100,000 users. Passionate about creating seamless automation workflows and developer-friendly APIs.

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 →