You step away from your Mac for a 15-minute coffee break. When you return and run a query in your database tool, your editor hangs for a few seconds before throwing an infuriating error:

ERROR 2006 (HY000): MySQL server has gone away
-- or:
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

This error is notorious among backend engineers and DBAs. It means the TCP connection between your database client and the MySQL server was terminated unexpectedly.

In this guide, we analyze the 3 distinct technical causes of Error 2006 and show you how to fix it permanently - including how SQLOZ automatically prevents timeout disconnects on macOS.

SQLOZ Native SQL Editor with Execution Controls and Keep-Alive Monitoring


1. The 3 Root Causes of Error 2006

Cause 1: Idle Server Timeout (wait_timeout)

By default, MySQL closes inactive connections after a specific period determined by two server variables:

  • wait_timeout (for non-interactive connections)
  • interactive_timeout (for interactive GUI clients)

If your database client does not send periodic background heartbeats (TCP keep-alives), the MySQL server closes the socket. When you execute your next query, the client sends packets across a dead socket, triggering Error 2006.

Cause 2: Exceeded Packet Size (max_allowed_packet)

If you execute a large INSERT statement containing high-resolution images, long JSON payloads, or multi-megabyte text dumps that exceed the server’s max_allowed_packet limit, MySQL considers the packet corrupt and forcefully closes the connection immediately.

Cause 3: macOS Sleep & Wi-Fi Switching

When you close your MacBook lid, macOS puts network interfaces to sleep. Remote firewalls, NAT gateways, and stateful cloud load balancers drop the TCP session tracking state. When your Mac wakes, the old socket is dead.


2. Server-Side Configuration Fixes

If you have root access to my.cnf (or AWS RDS Parameter Groups):

[mysqld]
# 1. Increase the maximum allowed packet size (e.g. to 64MB or 128MB)
max_allowed_packet = 64M

# 2. Increase the idle connection timeout (e.g. to 8 hours = 28800s)
wait_timeout = 28800
interactive_timeout = 28800

Restart MySQL to apply changes:

brew services restart mysql # Local Homebrew

3. How SQLOZ Solves Timeout Drops Automatically

While older database tools force you to disconnect and reconnect manually every time your laptop sleeps, SQLOZ implements automated session resilience:

  1. Intelligent TCP Keep-Alives: SQLOZ transmits lightweight ping packets across active sockets during idle periods, preventing cloud firewalls and MySQL timers from terminating the session.
  2. Instant Silent Auto-Reconnect: If your Mac wakes from sleep or you switch from Wi-Fi to a mobile hotspot, SQLOZ detects the dropped socket and transparently re-authenticates in the background.
  3. Session State Recovery: Your unsaved SQL tabs, cursor position, and transaction state are preserved, so you never lose your work mid-investigation.

Summary

“MySQL server has gone away” is almost always caused by idle server timeouts or undersized packet limits.

With SQLOZ, Mac developers get an intelligent client with built-in keep-alive pings and automatic silent reconnection, making timeout errors a thing of the past.

Download SQLOZ for macOS and enjoy uninterrupted database sessions today.