Questions tagged with Database

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

Connection reset by peer: Lost connection to MySQL server during query ([Errno 54]

I have a python application that is querying a MySQL Database (v `8.0.28`) hosted on AWS RDS. The code in the application looks something like this: import pymysql from sqlalchemy import create_engine user = 'usr1' pwd = 'pwd1' host = '' port = 3306 database = 'db1' engine = create_engine("mysql+pymysql://{}:{}@{}/{}".format(user,pwd,host,database)) con = engine.connect() query = ''' select * from db1.tbl1 ''' df = pd.read_sql(query, con) con.close() The application triggers a query upon loading and query returns successful results. However, after a few minutes (2-3) of idle time, I get an error when it tries to query the DB again / establish a connection. Error traceback: File "/Applications/Anaconda/anaconda3/lib/python3.9/site-packages/pymysql/", line 692, in _read_packet packet_header = self._read_bytes(4) File "/Applications/Anaconda/anaconda3/lib/python3.9/site-packages/pymysql/", line 738, in _read_bytes raise err.OperationalError( sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query ([Errno 54] Connection reset by peer)') [SQL: SELECT AS users_id, users.fullname AS users_fullname, AS users_email, users.password AS users_password, AS users_name FROM users WHERE = %(pk_1)s] [parameters: {'pk_1': 1}] (Background on this error at: We're trying to isolate the issue to whether this in on the Application side or DB host side.
asked a month ago