So I've been running into an error getting a connection from my Flask-SQLAlchemy Module to connect to my RDS proxy. Both the EC2 instance running the python and the DB are setup on the same VPC and I can visualize the DB running a psql command (I'm runnning the Aurora-postgres version on RDS) however cannot connect with my application, always getting this error:
File "/home/ec2-user/.local/lib/python3.7/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
File "/home/ec2-user/.local/lib/python3.7/site-packages/eventlet/support/psycopg2_patcher.py", line 46, in eventlet_wait_callback
state = conn.poll()
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Anyone encounter this? Here are my settings for the app.py for the Flask:
app.config['SECRET_KEY'] = '------------'
app.config['SQLALCHEMY_POOL_SIZE'] = 1
app.config['SQLALCHEMY_MAX_OVERFLOW'] = 0
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
# Flask-SQLAlchemy configuration
app.config['SQLALCHEMY_DATABASE_URI'] = getenv('DATABASE_URL', '-------------------------')
app.config['SQLALCHEMY_BINDS'] = {'logs': getenv(getenv('---------'))}
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_ENGINE_OPTIONS'] = {
'echo':False,
'pool_recycle':3600,
'pool_pre_ping':True,
'pool_use_lifo':True
}