Forums

DatabaseError: (psycopg2.DatabaseError) server closed the connection unexpectedly

I've been getting the error below occasionally, it's been hard to consistently reproduce, but occurs during my payment flow which is causing issues, any suggestions?

#012DatabaseError: (psycopg2.DatabaseError) server closed the connection unexpectedly#012#011This probably means the server terminated abnormally#012#011before or while processing the request.#012

is this for your webapp? how are you managing your db connections? django ORM? or sqlalchemy?

Yes, it's for seekwell.io, it's a Flask app using SQL Alchemy

SQLALCHEMY_DATABASE_URI = "postgresql://xxx@yyy-123.postgres.pythonanywhere-services.com:123/zzz"
db = SQLAlchemy(app)

That's very strange. I've checked your Postgres server, and it has been running without problems for several months -- and there's nothing in its logs. So I don't think it has terminated abnormally as the error message suggest it might have.

Is there a specific query or update that is triggering the problem?