Skip to content
TGWAY
Channels & Bots STEP 81 / 99

Reading Telegram API Errors: FLOOD_WAIT and Retries

Telegram API errors have a code and a name. What 303, 400, 401, 403, 420 and 500 mean, why you wait out FLOOD_WAIT_X, and how to handle unknown errors.

  • Applies toDevelopers
  • LevelL4
  • Reading time4 min
  • Verified

The short answer

  1. 1Each error has a number (category) and a name (reason); handle by name, fall back to number.
  2. 2FLOOD_WAIT_X: wait exactly X seconds before retrying.
  3. 3303 means switch data center; 401 means log in again.
In this article
  1. An error has a number and a name
  2. FLOOD_WAIT: waiting is the right answer
  3. The order of handling, in one line each
  4. FAQ
  5. At a glance

An error has a number and a name

Telegram API errors come in two parts: a numeric code, which is the broad category, and an error name in capitals and underscores, which is the specific reason, for example PHONE_CODE_INVALID. Decide what to do from the name, and fall back to the number when you meet a name you do not know. Where a name ends in _X, that part is a number: seconds, a data center number and so on.

CodeMeaningTypical names and what to do
303Go to another data centerPHONE_MIGRATE_X, USER_MIGRATE_X, FILE_MIGRATE_X, NETWORK_MIGRATE_X: move to data center X and repeat the request; see data centers and _MIGRATE errors
400The request is wrongThe input needs fixing; tell the user in plain words
401Login requiredAUTH_KEY_UNREGISTERED, SESSION_REVOKED, SESSION_EXPIRED: the session ended, log in again; see the login flow
403Not allowedThe other person's privacy settings or missing admin rights; sending again gives the same result
404It does not existA deleted message or chat, for example
406Something to tell the user separatelyYour app does not show this error itself; the server shows the user a service notice
420Too many requests, too fastFLOOD_WAIT_X: wait X seconds, then try again
500A problem on the serverTry again a little later; if it keeps happening, try a smaller request

Treat any number not in the table as a server-side problem (500). The official documentation lists possible errors for each method, but do not assume that list is complete; be ready for names you have never seen.

FLOOD_WAIT: waiting is the right answer

FLOOD_WAIT_X means "do not make this request for X seconds". Wait exactly that long, then send it again. Repeating the request while you are supposed to wait makes the wait longer, and doing it repeatedly can get the account restricted.

FLOOD_PREMIUM_WAIT_X is a speed limit that applies only to accounts without Premium, such as download speed for files; it does not apply to Telegram Premium accounts.

The real fix is fewer requests. Cache information instead of asking for it again and again (see pagination with offset and hash), and space out anything that sends to many chats.

The order of handling, in one line each

  1. If you know the name, act on the name: move, log in again, wait, or fix the input.
  2. If you do not know the name, act on the number.
  3. If you do not know the number either, treat it as a server problem and retry once, a little later.

Errors from the HTTP Bot API look slightly different (ok:false, error_code, description); see your first Bot API requests.

FAQ

What does FLOOD_WAIT mean in the Telegram API?

You made too many requests. FLOOD_WAIT_X tells you to wait X seconds before sending that request again.

What should I do with a 303 error?

Move to the data center number in the error name, such as USER_MIGRATE_X, and repeat the request there.

What do 401 errors like SESSION_REVOKED mean?

The session was ended, for example from the Devices list. Send the user back to log in.

Sources

Summary

At a glance

Reading Telegram API Errors: FLOOD_WAIT and Retries — at a glance illustration
  1. 1Name first

    The error name says what to do; the code is the fallback.

  2. 2FLOOD_WAIT

    Wait X seconds; retrying early makes it worse.

  3. 3Unknown

    Treat as a server problem and retry once, later.

Share this guide

Send it to a friend who has the same question.

Telegram WhatsApp
More

Open on your phonePoint your phone camera here to open this guide.

Updated

Related articles

View all ›