My PostgreSQL close unexpectedly the connection

Hello I’ve a PostgreSQL server which is presenting a problem that always says the server close the connection unexpectedly, how can I fix this? I am using flask This is the error:

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I have absolutely the same error with psycopg2 and can not find any solution. I submitted a ticket to the support. I can successfully connect with any GUI client or psql and make a query but it fails from within the application.

If anybody solved this?

We have same problem as well in digital ocean, we are unable to solve this issue. did you find any solution for that?


To learn more about what is happening here, it may be important for you to review the logs for Postgres. You can read more information about logging and error reporting on Postgres here: