Telegram bot 409 Conflict: terminated by other getUpdates request

Why your Telegram bot throws a 409 Conflict error about another getUpdates request, and how to stop the duplicate polling instance. Covers Node.js bots, webhooks and deploys.

You deploy a Telegram bot, or restart it on your laptop, and the logs fill up with this:

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

The bot stops answering, or it answers a few messages and then goes quiet. The code is usually fine. Two copies of the bot are asking Telegram for updates with the same token at the same time.

A polling bot keeps a long request open to Telegram's getUpdates method and reads new messages from it. Telegram allows only one of these open per bot token. When a second process starts polling, Telegram rejects one side with a 409. Which side wins depends on timing, so the bot may work for a minute and then fail again.

1 An old instance is still running during a redeploy

This is the most common cause on hosted platforms. When you push a new version, the platform often starts the new container before the old one has fully stopped. For a few seconds, sometimes longer if the old process ignores the stop signal, both are polling.

To confirm it, look at the logs right after a deploy. If the 409 appears only around deploy time, or you see two startup messages close together, this is your cause. Then check how many instances the service runs. On Railway and Render, look for "replicas" or "instances" in the service settings, since the exact wording may change. On Heroku, list the running processes:

heroku ps

If more than one worker is running, scale it to one:

heroku ps:scale worker=1

On Fly.io, check and set the machine count:

fly status
fly scale count 1

For a polling bot, one instance is the right number. Scaling up does not make it faster. It just creates more pollers.

2 A forgotten local copy is still running

You start the bot on your laptop to test a change, then close the editor but leave the terminal open. Or you started it under PM2 or Docker and forgot. The local copy and the hosted copy now fight over the same token.

To confirm, pause the hosted service for a minute. If the 409s stop, something else is polling. Find it on your machine. On macOS or Linux:

ps aux | grep node

On Windows, open Task Manager or run tasklist. If you use PM2, run pm2 list. If you use Docker, run docker ps.

Then stop what you do not need:

pm2 delete <app-name>
docker stop <container-id>
kill <pid>

3 A webhook is still set on the token

If you ever set up a webhook for this bot, Telegram keeps it until you remove it. While a webhook is active, getUpdates is refused, and the error text is different. You may see something like "can't use getUpdates method while webhook is active". Your polling bot then fails even when nothing else is running, because an old webhook URL is still registered.

To check, call getWebhookInfo with your token:

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

If the url field is not empty, a webhook is set. If you want polling, remove it:

curl https://api.telegram.org/bot<YOUR_TOKEN>/deleteWebhook

Add ?drop_pending_updates=true to the end of that URL if you want Telegram to throw away messages that were queued while the bot was down. Keep your token out of screenshots and shared logs, because anyone with it can control the bot.

4 Stop cleanly on shutdown

Even with one instance, a redeploy can overlap with the old process for a moment. A clean shutdown helps the old instance release the token sooner.

Here is a Telegraf example. Install it with npm install telegraf.

const { Telegraf } = require('telegraf');

const bot = new Telegraf(process.env.BOT_TOKEN);

bot.start((ctx) => ctx.reply('The bot is running.'));
bot.on('text', (ctx) => ctx.reply(`You said: ${ctx.message.text}`));

console.log('Starting bot');
bot.launch().catch((err) => {
  console.error('Could not start bot:', err);
  process.exit(1);
});

function shutdown(signal) {
  console.log(`Got ${signal}, stopping bot`);
  bot.stop(signal);
}

process.once('SIGINT', () => shutdown('SIGINT'));
process.once('SIGTERM', () => shutdown('SIGTERM'));

The shutdown handler matters because most hosting platforms send SIGTERM to the old container before replacing it. Calling bot.stop() ends Telegraf's polling loop, so the old instance lets go of the token. If you use node-telegram-bot-api instead, call bot.stopPolling() in the same place.

If the 409 still shows up after a redeploy, restart the service once and check the logs again. If it keeps coming back, sections 1 to 3 are the likely cause.

If you run several instances on purpose, or you need the bot to stay up through many deploys, switch from polling to a webhook. With a webhook, Telegram sends each update to a public HTTPS URL you control, so there is no long-poll to fight over and any instance behind your load balancer can answer. You register the URL with setWebhook, and Telegraf provides bot.webhookCallback() to handle the requests. It needs a domain with valid HTTPS, so it is more setup than polling, but it is the right design for production.

Still stuck?

If the 409 keeps coming back after you have one instance and a clean shutdown, the cause is often a platform setting or an old process you cannot see from the logs. Send me the hosting platform, your start command and the output of getWebhookInfo with the token removed, and I can usually find it quickly. this is the kind of fix I do

FAQ

Quick answers

What does 409 Conflict terminated by other getUpdates request mean?

It means another process is already polling Telegram for updates with the same bot token. Telegram allows only one active getUpdates long-poll per token, so the second one gets rejected. Stop the extra process, or make sure only one instance runs.

How do I remove a webhook so my polling bot works?

Call the deleteWebhook method with your bot token, for example at https://api.telegram.org/bot<YOUR_TOKEN>/deleteWebhook. First call getWebhookInfo to see whether a URL is set. A webhook also blocks getUpdates, so it can cause a similar error.

Should I use a webhook instead of polling for a Telegram bot?

For a bot that runs on one instance, polling is fine. For a bot that runs on multiple instances or redeploys often, a webhook is the better choice, because Telegram pushes updates to one HTTPS URL and no long-poll is held open. Webhooks need a public domain with valid HTTPS.