# Telegram Connection Failed — WebSocket Error 1006 — OpenClaw Help

Fix Telegram connection failed and WebSocket error 1006 in OpenClaw. Step-by-step guide for bot token issues, proxy problems, network errors, and reconnection.


## 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:

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

If it returns `} 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

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

`}

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

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:

- **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&lt;TOKEN&gt;/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 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.

Try Managed Hosting — 7-Day Free Trial →

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


---
