python-gino/gino-starlette

Cannot connect to the database; max retries reached.

bakhtiyorovdilshod opened this issue · 1 comments

Expected Behavior

Describe what you were trying to get done and what you expected to happen.
Cannot connect to the database; max retries reached.
ERROR: Traceback (most recent call last):
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/starlette/routing.py", line 526, in lifespan
async for item in self.lifespan_context(app):
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/starlette/routing.py", line 467, in default_lifespan
await self.startup()
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/starlette/routing.py", line 502, in startup
await handler()
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/gino_starlette.py", line 183, in startup
**config["kwargs"],
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/gino_starlette.py", line 226, in set_bind
return await super().set_bind(bind, loop=loop, **kwargs)
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/gino/api.py", line 417, in set_bind
bind = await create_engine(bind, loop=loop, **kwargs)
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/gino/strategies.py", line 55, in create
pool = await dialect.init_pool(u, loop, pool_class=pool_class)
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/gino/dialects/asyncpg.py", line 465, in init_pool
return await pool_class(url, loop, init=self.on_connect(), **self._pool_kwargs)
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/gino/dialects/asyncpg.py", line 218, in _init
self.pool = await asyncpg.create_pool(**args)
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/asyncpg/pool.py", line 398, in async__init

await self._initialize()
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/asyncpg/pool.py", line 426, in _initialize
await first_ch.connect()
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/asyncpg/pool.py", line 125, in connect
self._con = await self._pool._get_new_connection()
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/asyncpg/pool.py", line 472, in _get_new_connection
**self._connect_kwargs)
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/asyncpg/connection.py", line 1727, in connect
max_cacheable_statement_size=max_cacheable_statement_size)
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/asyncpg/connect_utils.py", line 674, in _connect
raise last_error
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/asyncpg/connect_utils.py", line 666, in _connect
connection_class=connection_class)
File "/home/dilshod/Desktop/dev_appointment/my_env/lib/python3.7/site-packages/asyncpg/connect_utils.py", line 633, in _connect_addr
connector, timeout=timeout)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 412, in wait_for
return fut.result()
File "uvloop/loop.pyx", line 1914, in create_connection
socket.gaierror: [Errno -2] Name or service not known

ERROR: Application startup failed. Exiting.

I could not connect my database.

Hello @bakhtiyorovdilshod I had the same problem and I fixed doing two things:

  • .env on root folder;
  • Considered any parameters as string;

I hope it fixes for you.