Pyrogram supports proxies with and without authentication. This feature allows Pyrogram to exchange data with Telegram through an intermediate SOCKS5 proxy server.
To use Pyrogram with a proxy, simply append the following to your
config.inifile and replace the values with your own settings:
[proxy] enabled = True hostname = 188.8.131.52 port = 1080 username = <your_username> password = <your_password>
To enable or disable the proxy without deleting your settings from the config file, change the
enabledvalue as follows:
on: Enables the proxy
off: Disables the proxy
Alternatively, you can setup your proxy without the need of the
config.inifile by using the proxy parameter in the Client class:
from pyrogram import Client app = Client( session_name="example", proxy=dict( hostname="184.108.40.206", port=1080, username="<your_username>", password="<your_password>" ) ) app.start() ...
If your proxy doesn’t require authorization you can omit
password by either leaving the
values blank/empty or completely delete the lines.