Software⏱️ 2 min read📅 2026-05-30

How to Fix: Error Code: 2013. Lost connection to MySQL server during query

MySQL server connection timeout issue resolved by increasing the timeout value.

Quick Answer: Increase the MySQL query timeout using the 'set session variable' command or configure the MySQL server to increase its default timeout.

Error Code: 2013 is a common issue in MySQL that occurs when the connection to the MySQL server is lost during a query. This error can be caused by various factors, such as a slow network connection, a misconfigured MySQL server, or an overloaded database.

⚠️ Common Causes

  • Slow network connection
  • Misconfigured MySQL server
  • Overloaded database

🚀 How to Resolve This Issue

Method 1: Increase MySQL Timeout Value

  1. Step 1: Open the my.cnf or my.ini file in a text editor and locate the wait_timeout and init_connect parameters.

Method 2: Optimize MySQL Server Configuration

  1. Step 1: Increase the max_connections, key_buffer_size, and read_rnd_table_size parameters to improve performance.

🎯 Final Words

To resolve the Error Code: 2013 issue, you can try increasing the MySQL timeout value or optimizing your MySQL server configuration. Additionally, ensure that your network connection is stable and your database is not overloaded.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions