"could not connect" means your server is unreachable from a network standpoint. You want to make sure the server is running and that it is routable over the network you are trying to connect from.
in an HA scenario, depending on what software is in use and how it does switchover, there can be long network lags, such as if it is moving a VIP from one machine to another. You'd want to be using a proxy server such as HAProxy or PGBouncer rather than relying upon changing network routing. On Tue, Feb 25, 2020, at 12:07 PM, Karim Gillani wrote: > Please note I am using a Pool. And some other connections seem to recover > fine. After two minutes I get this message and things start working again: > > ==> AE K:11oh392; T:1; E:(psycopg2.OperationalError) could not connect to > server: Connection timed out> Is the server running on host > "patroni-mastertheq" (172.50.46.180) and accepting> TCP/IP connections on > port 5432?>>(Background on this error at: http://sqlalche.me/e/e3q8 ) > Thanks > Karim > > On Tuesday, 25 February 2020 08:49:19 UTC-8, Karim Gillani wrote: >> I am having an issue where when my HA postgres database drops and is >> automatically moved to a backup database, the timeout doesn't seem to be >> working. >> >> My config.py shows the following: >> >> SQLALCHEMY_DATABASE_URI = >> '{engine}://{user}:{password}@{host}:{port}/{name}'.format( >> >> engine=DB_ENGINE, >> >> user=DB_USER, >> >> password=DB_PASSWORD, >> >> host=DB_HOST, >> >> port=DB_PORT, >> >> name=DB_NAME, >> >> ) >> SQLALCHEMY_ENGINE_OPTIONS >> = { 'pool_size' : pool_size, 'max_overflow' : max_overflow, 'pool_pre_ping' >> : True, 'pool_timeout': DB_POOL_TIMEOUT, 'pool_recycle': 3600, >> 'connect_args': { 'connect_timeout': 5, 'options' : '-c >> statement_timeout=5000' } } >> >> Is there something I set wrong? My timeout seems to be about 2 minutes >> instead of 5 secs. >> >> Any help would be appreciated, >> >> Thanks >> Karim >> > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/ab3e5681-d9be-468f-8160-97bddcca57fb%40googlegroups.com > > <https://groups.google.com/d/msgid/sqlalchemy/ab3e5681-d9be-468f-8160-97bddcca57fb%40googlegroups.com?utm_medium=email&utm_source=footer>. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/78c2b7d9-32a2-4ffa-9c46-f746f5206335%40www.fastmail.com.