The short answer
- 1Each account has one home data center; each file carries its dc_id.
- 2On a _MIGRATE_X error, move to data center X and retry; get addresses from help.getConfig.
- 3Keys are per data center; move a login with exportAuthorization and importAuthorization.
In this article
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.
| What | Where it belongs |
|---|---|
| A user account | One 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 transfers | May 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.
| Error | When | What to do |
|---|---|---|
PHONE_MIGRATE_X | During login: this phone number's home is X | Connect to X and start the login again |
USER_MIGRATE_X | A logged-in user's request: their home is X | Make X your main connection |
NETWORK_MIGRATE_X | Use X instead of the current connection | Move to X and repeat the request |
FILE_MIGRATE_X | Uploading or downloading: the file is on X | Open 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.
- On the current data center, call
auth.exportAuthorizationwith the target data center's number and receive a one-time authorization value. - Connect to the target data center (with a new key) and pass that value to
auth.importAuthorization. - 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
At a glance
- 1Where
Accounts have a home DC; files have dc_id.
- 2Errors
PHONE, USER, NETWORK and FILE _MIGRATE_X tell you where to go.
- 3Keys
New key per DC; export/import authorization to stay logged in.
Updated