Skip to content
Node.js and Python3 min read

Telegram bot error 409 Conflict

Conflict: terminated by other getUpdates request; make sure that only one bot instance is running

Short answer

409 Conflict means Telegram received getUpdates requests from more than one place with the same bot token, or a getUpdates request while a webhook is active. Run exactly one instance in one mode: stop the duplicate process (often a copy on your own computer), call `deleteWebhook` if you use polling, or stop polling if you use a webhook.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. The two forms of the error
  2. Causes
  3. How to fix it, step by step
  4. Prevention
  5. On ArabyHost

A bot gets messages in one of two ways. With long polling, your code keeps calling getUpdates and Telegram answers with new messages. With a webhook, Telegram sends each update to an HTTPS URL you registered. Telegram allows only one active getUpdates connection per token, and no polling at all while a webhook is set. When that rule is broken, it answers with error 409.

The two forms of the error

Message Meaning
Conflict: terminated by other getUpdates request; make sure that only one bot instance is running Two processes poll with the same token
Conflict: can't use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first A webhook is set, but your code uses polling

Libraries wrap the same text: telegram.error.Conflict in python-telegram-bot, TelegramConflictError in aiogram, 409: Conflict in Telegraf and node-telegram-bot-api.

Causes

  • The bot still runs on your computer while the server copy starts.
  • Two copies on the server: a cron job that starts a new process every minute without checking, or an old process left over after a deploy.
  • The polling bot is run as a web app, so the app server starts it in more than one process.
  • A webhook from an earlier setup is still registered.
  • Someone else has the token, for example from a public repository.

How to fix it, step by step

  1. Choose one mode. A polling bot is a background worker; a webhook bot is a web app that answers Telegram’s HTTPS requests.

  2. Stop every copy you know about. Close it on your computer, then on the server:

    pgrep -af bot.py      # list running copies
    pkill -f bot.py       # stop them all
  3. Check the webhook status (replace <TOKEN>):

    curl "https://api.telegram.org/bot<TOKEN>/getWebhookInfo"

    If url isn’t empty and you want polling, remove it. drop_pending_updates=true also discards queued old messages:

    curl "https://api.telegram.org/bot<TOKEN>/deleteWebhook?drop_pending_updates=true"
  4. If you want a webhook instead, register your URL with setWebhook and remove all polling code (run_polling, bot.launch() in polling mode, start_polling).

  5. Start exactly one instance. For a polling worker kept alive with cron, flock makes sure a second copy never starts while the first one runs:

    * * * * * /usr/bin/flock -n /home/USER/bot.lock /home/USER/virtualenv/bot/3.11/bin/python /home/USER/bot/bot.py >> /home/USER/bot/bot.log 2>&1

    The cron generator helps with the schedule part.

  6. If 409 continues with nothing running, revoke the token in @BotFather (/revoke), update the new API token on the server only, and start again.

Prevention

  • Use a separate test bot (its own token) on your computer, never the production token.
  • In every deploy, stop the old process before starting the new one.
  • Keep the token in an environment variable or .env, never in the repository.

On ArabyHost

On ArabyHost AI/Developer plans, Python 3.9 to 3.12 and Node.js 20/24 bots run in their own environment created by cPanel’s Setup Python App or Setup Node.js App. A polling bot is a long-running worker, kept alive with a cron job as shown above; a webhook bot runs as a Passenger web app on your domain with free SSL. Don’t run polling inside the web app. The Telegram bot guide covers both setups, and Telegram bot hosting explains which plan fits.

FAQ

Should a Telegram bot use polling or a webhook?

Polling is simpler: one long-running process asks Telegram for updates, which suits a background worker. A webhook needs a public HTTPS URL that Telegram calls, which suits a web app. Pick one; using both causes 409.

I stopped everything and still get 409. Why?

Another copy may be running somewhere you forgot, such as an old server or a teammate's laptop, or the token has leaked. Revoke the token in @BotFather with `/revoke`, put the new token in your server's configuration, and start one instance.

Is one 409 right after a restart a problem?

Usually not. The previous long-polling request can stay open for a few seconds after a restart and is ended with a 409. A steady stream of 409 errors means two instances are really running.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.