Skip to content
TGWAY
Channels & Bots STEP 82 / 99

Telegram Data Centers: _MIGRATE Errors and Switching DCs

Accounts and files live in specific Telegram data centers. Get the list from help.getConfig, handle _MIGRATE_X errors and move with exportAuthorization.

  • Applies toDevelopers
  • LevelL4
  • Reading time4 min
  • Verified

The short answer

  1. 1Each account has one home data center; each file carries its dc_id.
  2. 2On a _MIGRATE_X error, move to data center X and retry; get addresses from help.getConfig.
  3. 3Keys are per data center; move a login with exportAuthorization and importAuthorization.
In this article
  1. Telegram's servers are split across data centers
  2. Getting the list of data centers
  3. Errors that say "go somewhere else"
  4. Each data center has its own key
  5. Moving without logging in again
  6. FAQ
  7. At a glance

Telegram's servers are split across data centers

Telegram's servers are divided among data centers (DCs) in several regions, each identified by a number. Every account belongs to one data center, its "home", and every file carries the number of the data center where it is stored (dc_id). The official apps and TDLib handle this for you; if you work with MTProto directly, it is your job.

WhatWhere it belongs
A user accountOne fixed home data center
A file (photo, video, document)Each file has a dc_id, and can be downloaded straight from that data center
Large file transfersMay have separate media-only connections and a CDN

Getting the list of data centers

Your app first connects to any data center, then calls help.getConfig. The data center list inside it (dcOptions) gives each one's number, address and port, plus flags such as "media only" and "CDN". Do not hard-code addresses; store this list and use it. The server address on your app's page at my.telegram.org is only the place to make that first connection; see getting an api_id.

Errors that say "go somewhere else"

When a request goes to the wrong data center, a 303 error comes back with the destination number at the end of its name; see reading API errors.

ErrorWhenWhat to do
PHONE_MIGRATE_XDuring login: this phone number's home is XConnect to X and start the login again
USER_MIGRATE_XA logged-in user's request: their home is XMake X your main connection
NETWORK_MIGRATE_XUse X instead of the current connectionMove to X and repeat the request
FILE_MIGRATE_XUploading or downloading: the file is on XOpen a file connection to X and repeat

Each data center has its own key

The authorization key used for encryption does not carry over between data centers. The first time you connect to a new one, you create a new key for it; see creating an authorization key. Store keys and sessions separately for each data center.

Moving without logging in again

If the user is logged in on their home data center and you need a file stored on another one, you do not have to make them log in again.

  1. On the current data center, call auth.exportAuthorization with the target data center's number and receive a one-time authorization value.
  2. Connect to the target data center (with a new key) and pass that value to auth.importAuthorization.
  3. You can now make requests there as the same user.

One authorization key can have several sessions (connections) open at once, so apps often keep one connection for messages and another for large files; see uploading and downloading files.

FAQ

What does PHONE_MIGRATE_X mean?

The phone number's account lives in data center X. Connect there and start the login again.

How do I get Telegram's data center addresses?

Call help.getConfig after connecting; dcOptions lists each data center's number, address and port.

Do I need to log in again on another data center?

No. Use auth.exportAuthorization on the current one and auth.importAuthorization on the new one.

Sources

Summary

At a glance

Telegram Data Centers: _MIGRATE Errors and Switching DCs — at a glance illustration
  1. 1Where

    Accounts have a home DC; files have dc_id.

  2. 2Errors

    PHONE, USER, NETWORK and FILE _MIGRATE_X tell you where to go.

  3. 3Keys

    New key per DC; export/import authorization to stay logged in.

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 ›