A proxy can listen on IPv6 while carrying a connection to a Telegram server on another address family. Treat the proxy endpoint and the final Telegram endpoint separately.

For Telethon 1.45 with its documented python-socks[asyncio] dependency available in the application's environment:

from telethon import TelegramClient

client = TelegramClient(
    'existing-session', api_id, api_hash,
    proxy={
        'proxy_type': 'socks5',
        'addr': '2001:db8::10',
        'port': 1080,
        'rdns': True,
    },
)

Replace the documentation IPv6 address and port with the actual listener. The address field is a literal without brackets, because the port is already a separate value. Brackets are needed when embedding an IPv6 address in a URL authority.

Add username and password fields for a SOCKS account when required. A SOCKS5 account is separate from Telegram's API ID, API hash and session.

use_ipv6=True controls Telethon's choice of Telegram server address. It is not the switch that turns an IPv6 proxy hostname into a valid listener address.

Check the backend available to the actual Python interpreter when an older environment fails on IPv6. An import in another virtual environment does not change this process. MTProto proxy connection modes use a different tuple containing a secret; that is another configuration.

ХӀокхунах тера йаззамаш