skip to Main Content

I tried to deploy my Telethon bot on PythonAnywhere but got following exception:

Attempt 1 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)
Attempt 2 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)
Attempt 3 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)
Attempt 4 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)
Attempt 5 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)
Attempt 6 at connecting failed: ConnectionRefusedError: [Errno 111] Connect call failed ('149.154.167.51', 443)
Traceback (most recent call last):
  File "/home/hellbowe/popa3/main.py", line 51, in <module>
    clientg.start(phone_tg, password_tg)
  File "/home/hellbowe/.local/lib/python3.9/site-packages/telethon/client/auth.py", line 133, in start
    else self.loop.run_until_complete(coro)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/hellbowe/.local/lib/python3.9/site-packages/telethon/client/auth.py", line 140, in _start
    await self.connect()
  File "/home/hellbowe/.local/lib/python3.9/site-packages/telethon/client/telegrambaseclient.py", line 525, in connect
    if not await self._sender.connect(self._connection(
  File "/home/hellbowe/.local/lib/python3.9/site-packages/telethon/network/mtprotosender.py", line 127, in connect
    await self._connect()
  File "/home/hellbowe/.local/lib/python3.9/site-packages/telethon/network/mtprotosender.py", line 253, in _connect
    raise ConnectionError('Connection to Telegram failed {} time(s)'.format(self._retries))
ConnectionError: Connection to Telegram failed 5 time(s)

It works fine on my device.

I tried to add proxy to TelegramClient() thing but got this:

Traceback (most recent call last):
  File "/home/hellbowe/popa3/main.py", line 51, in <module>
    clientg = TelegramClient('popa3', api_id_tg, api_hash_tg, proxy = ('http', '***', 80))
  File "/home/hellbowe/.local/lib/python3.9/site-packages/telethon/client/telegrambaseclient.py", line 292, in __init__
    session.set_dc(
  File "/home/hellbowe/.local/lib/python3.9/site-packages/telethon/sessions/sqlite.py", line 168, in set_dc
    self._update_session_table()
  File "/home/hellbowe/.local/lib/python3.9/site-packages/telethon/sessions/sqlite.py", line 194, in _update_session_table
    c.execute('delete from sessions')
sqlite3.OperationalError: database is locked

2

Answers


  1. You have some other process that has locked your sqlite database (or the database is corrupted) Try deleting the database file or moving it somewhere else so that it can be recreated.

    Login or Signup to reply.
  2. As far as I know, you need to log in into Telegram to use telethon. In your machine you can do it with command line interface, but in hosting you can’t. I solved this problem when rent a virtual server, where I can log in Telegram. Then I just run python script with some options in order to always working

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search