title: SQLAlchemy - Postgres Connection Issue while running via Flask
body: <p>Flask with SQLAlchemy 
  Flask==0.10.1
  SQLAlchemy==1.0.8</p>
  
  <p>In production after a lot of usages (connection) we are getting this error. After that restarting the server helps, what will be the permanent solution</p>
  
  <p>OperationalError: (psycopg2.OperationalError) server closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request.\</p>
  
  <p>Similarly, we are creating a scoped session, we are doing session.close()</p>
  
  <p><strong>I tried Null Pool which doesn't help</strong></p>
  
  <p>Any ideas on that?</p>
  
  <p>Relevant finding
  <a href="https://stackoverflow.com/questions/8824826/is-it-odd-that-my-sqlalchemy-mysql-connection-always-ends-up-sleeping">Is it odd that my SQLAlchemy MySQL connection always ends up sleeping?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3033234/handle-mysql-restart-in-sqlalchemy">Handle mysql restart in SQLAlchemy</a></p>