I faced this error when my front end connected with python server in flask to save a new issue to postgres.

Flask Server was written to get the details of the new issue and save it to postgres, when once started it will open a connection to postgres and wait for request from front end.

Once I started this it will work for 1 or 2 requests that come immediately and then if i just leave and re-try after lets say 30 minutes, the server will hang.

At first i though this is issue with flask , but after further debugging i saw that the issue was with the OPEN CONNECTION TO POSTGRES which was timing out. This again is not issue with postgres or python postgres api psycopg2, it is how the connection works with postgres, if left idle for long the tcp connection will time out.

I Solved this issue by creating a new connection of every request that comes and and close the connection when request competes.

results matching ""

    No results matching ""