Use Cases 4 min read

Proxies for Telegram: SOCKS5 Setup for the App, Bots and Telethon

Telegram has proxy support built in. Here is how to configure SOCKS5 in the apps, and how to route bots and Telethon scripts through a stable IP.

Telegram is one of the few apps with proxy settings built in, which makes proxies for Telegram simple to set up compared with most platforms. People use them to keep a business account's connection stable on restrictive networks, to run bots from servers whose IP they do not want exposed, and to keep developer test accounts on separate IPs. This guide covers the apps, the Bot API and Telethon.

Use SOCKS5 with Telegram

Telegram's apps support SOCKS5 and Telegram's own MTProto proxy type. A SOCKS5 proxy with a username and password works on every official app. Use the SOCKS5 endpoint and your credentials:

Server:   global.nodeproxies.xyz
Port:     1080
Username: USERNAME-country-us-session-tg01-time-1440
Password: PASSWORD

Use a sticky session. Telegram keeps long-lived connections and reconnects in the background; if every new connection arrived from a different IP, you would see more reconnects and security notices. The time value is in minutes, so 1440 keeps the same IP for up to a day. Our SOCKS5 vs HTTP proxies article explains why SOCKS5 suits apps like this.

Setting It Up in the Telegram Apps

  • Desktop: Settings, then Advanced, then Connection type, then Use custom proxy. Add a proxy, choose SOCKS5, and fill in server, port, username and password.
  • Android: Settings, then Data and Storage, then Proxy Settings. Add proxy, choose SOCKS5, enter the details and enable it.
  • iPhone: Settings, then Data and Storage, then Proxy. Add a proxy, choose SOCKS5 and fill in the fields.

Menu names shift slightly between app versions, but proxy settings always live under data or connection settings. Once enabled, the app shows the proxy status and connection speed. Mobile setup for other apps is in our Android proxy setup and iPhone proxy setup guides.

Routing a Telegram Bot Through a Proxy

Bots talk to the Bot API over plain HTTPS, so any HTTP client works. With Python requests and SOCKS support installed (pip install requests[socks]):

import requests

TOKEN = '123456:ABC-YOUR-BOT-TOKEN'
PROXY = 'socks5h://USERNAME-country-us-session-bot01-time-1440:[email protected]:1080'
proxies = {'http': PROXY, 'https': PROXY}

me = requests.get(f'https://api.telegram.org/bot{TOKEN}/getMe', proxies=proxies, timeout=30)
print(me.json())

requests.post(f'https://api.telegram.org/bot{TOKEN}/sendMessage',
              json={'chat_id': 123456789, 'text': 'Hello from behind a proxy'},
              proxies=proxies, timeout=30)

The socks5h scheme makes DNS resolution happen on the proxy side, which avoids DNS lookups leaking from your server. You can use the HTTP endpoint (http://[email protected]:8080) instead if your library supports only HTTP proxies.

Telethon Clients Through a Proxy

Telethon, the popular Python library for the Telegram client API, accepts a proxy tuple when you install python-socks (pip install telethon python-socks):

from telethon import TelegramClient

api_id = 12345
api_hash = 'your_api_hash'
proxy = ('socks5', 'global.nodeproxies.xyz', 1080, True,
         'USERNAME-country-us-session-tl01-time-1440', 'PASSWORD')

client = TelegramClient('my_account', api_id, api_hash, proxy=proxy)

async def main():
    me = await client.get_me()
    print('Logged in as', me.username)

with client:
    client.loop.run_until_complete(main())

The fourth value (True) enables remote DNS. Keep the same session ID for the same Telegram account every time, and use a country that matches where the account normally connects - a sudden jump to another continent can trigger a login confirmation. Use Telethon for your own account and automation that follows Telegram's terms; mass messaging and scraping members of groups for spam are prohibited.

Troubleshooting Telegram Proxy Connections

  • The app stays on Connecting: check the port is 1080 for SOCKS5 (8080 is the HTTP endpoint, which the Telegram apps do not use).
  • Authentication errors: the username includes the targeting options, so copy it exactly; a stray space breaks it. A 407-style failure means wrong credentials or an inactive plan - see SOCKS5 authentication failed.
  • Works for a while, then stops: the plan may be out of bandwidth. Check usage in the dashboard and top up.
  • Frequent reconnects: make sure you are using a session ID with a long time value rather than a rotating username.

Choosing a Proxy Type for Telegram

Telegram messaging uses little bandwidth; media downloads use more. Residential proxies give a normal consumer IP for personal and business accounts, from $0.65/GB. For bots running on servers, datacenter proxies from $0.42/GB are often enough since bots are expected to run from servers. For phone-based accounts, mobile proxies match carrier networks. Turn off media auto-download in the app to keep usage low.

Getting Started with NodeProxies

Create an account, add from $3 by card or crypto, buy a plan from 100 MB, and use the SOCKS5 endpoint on port 1080 with a sticky session in the username. No subscription or ID check, and your balance never expires. If authentication fails, see how to fix proxy error 407. Plans are on the pricing page.

FAQ

How do I add a SOCKS5 proxy to Telegram?

Open Telegram's data and storage or connection settings, add a proxy, choose SOCKS5, and enter the server, port 1080, username and password.

Does Telegram support proxies with a username and password?

Yes. SOCKS5 proxies in the official apps accept a username and password.

Should I use a rotating proxy for Telegram?

No. Use a sticky session so the account keeps one IP; Telegram reconnects often and frequent IP changes cause instability.

NodeProxies

Ready to get started?

90M+ residential, mobile & datacenter proxies. Datacenter from $0.30/GB, residential from $0.42/GB. No contracts.

Create free account