Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk11 min

How to Fix MySQL Error 2013: Lost Connection at Initial Handshake

ERROR 2013 at the initial handshake happens before normal authentication. This guide shows how to isolate listener, network, protocol, DNS, host-cache, proxy, and timeout causes without guessing.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

MySQL Error 2013 at “reading initial communication packet” means the client disconnected before authentication and session setup finished. Start by proving that the intended MySQL service is running, listening on the expected interface and port, and reachable over TCP. Then verify that the client uses the matching protocol, check DNS and grant behavior, inspect host-cache blocks, and only then adjust connect_timeout. A longer timeout cannot repair a closed port, an incorrect bind address, a firewall drop, or a classic-client/X Protocol mismatch.

This order works for the common case in which MySQL succeeds on the server itself but fails from an application host. It also prevents a risky configuration change from masking the original fault or creating a second access problem.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What ERROR 2013 means during the initial handshake

MySQL normally accepts a socket connection, sends an initial handshake packet, negotiates capabilities and authentication, and then creates the session. ERROR 2013 at reading or waiting for the initial communication packet says that sequence stopped before normal authentication completed.

The MySQL manual identifies network connectivity as the usual class of cause. For a failure specifically at initial connection, a connect_timeout that is too short can also terminate a slow exchange. The server-side counter Aborted_connects helps show whether initial attempts are being abandoned by the server. The error text alone does not identify which layer failed, so treat it as a location in the connection timeline, not as a diagnosis.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
  • Listener or service: mysqld is stopped, bound only to loopback, configured with skip_networking, or listening on a different port.
  • Network path: a host firewall, cloud security group, route, container mapping, tunnel, proxy, or router drops or misdirects the connection.
  • Protocol: a classic-protocol client is sent to an X Protocol listener, commonly port 33060, instead of the classic listener, commonly port 3306.
  • Name and grant processing: reverse or forward DNS is slow or failing, or the account’s Host value does not match the connecting address.
  • Host-cache protection: repeated interrupted handshakes cause MySQL to block a source host.
  • Timeout: the server is reachable but takes longer than the client or server’s initial-connection timeout to answer.

Use the same destination name or address, port, protocol, and network path that the failing application uses. A successful test against a different endpoint is not evidence that the application endpoint works.

Fast triage: identify the failing layer before changing settings

Observation Most likely layer Next check
nc -vz DB_HOST 3306 is refused immediately Service, listener, bind address, or an active reject rule Confirm mysqld, listening address, port, and firewall policy.
The TCP probe times out Routing or filtering Check security groups, host firewalls, network ACLs, tunnel paths, and container mappings.
TCP opens, but a classic mysql client reports ERROR 2013 immediately Wrong protocol/port or an intermediary that cannot reach its backend Use the classic listener, normally 3306; verify every proxy or router hop.
Only hostname connections fail; an IP test behaves differently DNS lookup or grant matching Check forward and reverse DNS, skip_name_resolve, and account Host values.
A previously working source now fails after many interrupted attempts Host-cache block Inspect performance_schema.host_cache and clear the cache if the source is legitimate.
TCP is reliable but the initial packet arrives slowly Initial timeout Increase connect_timeout cautiously and compare Aborted_connects before and after.

The table is a routing aid, not proof. Confirm the hypothesis with the server error log, connection counters, and the network device that owns the suspected hop.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

1. Confirm the endpoint and MySQL listener

Verify that the server process is running

On the database host, confirm that the MySQL service is actually running and that it has not restarted or failed. Use the service manager appropriate to the operating system, then inspect the MySQL error log for startup, bind, or port errors. A client cannot complete a handshake with a stopped process, even if DNS and firewall rules are correct.

Check the configured port and interface

The conventional classic MySQL protocol port is 3306. Confirm the effective port setting rather than assuming it, especially after a migration, container deployment, or managed-service change. Check the listening sockets from the server host and identify both the port and local address. A listener on 127.0.0.1 accepts loopback connections only; a remote client needs an address reachable from its network.

If the server was started with skip_networking, it accepts no TCP/IP connections at all. Local commands may still work through a Unix socket, which can make this setting easy to overlook. Remove or change the setting only when your security design permits TCP access, and restart or reload MySQL according to the version’s configuration rules.

Account for intermediaries

For a container, verify that the host port is published to the container’s MySQL port and that the application is using the published address, not an unreachable container address. For an SSH tunnel, confirm that the local forwarded port is open and that the tunnel’s remote target is correct. For a database proxy or router, check both the client-facing listener and its backend route. An intermediary can accept a TCP connection and still emit a handshake-stage 2013 when it cannot reach a healthy MySQL backend.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

2. Prove TCP reachability from the client network

Run the test on the same machine, subnet, container, or serverless runtime that produces the error. Substitute the actual destination and port:

nc -vz DB_HOST 3306

If netcat is unavailable, an environment-appropriate Telnet probe can perform the same basic port check:

telnet DB_HOST 3306

A successful TCP connection proves only that something accepted the socket. It does not prove that the endpoint is MySQL, that the protocol is correct, or that authentication will succeed. Immediately retry with the exact MySQL client options used by the application, including hostname, port, TLS mode, and user where applicable.

  • Connection refused: the destination was reachable but no process accepted the port, or a device actively rejected it. Recheck the service, port, bind address, and reject rules.
  • Timeout: packets are being filtered, routed incorrectly, or sent to an address that cannot respond. Investigate security groups, host firewalls, network ACLs, VPNs, and routes.
  • TCP succeeds, then the client fails at the initial packet: focus on protocol pairing, proxies, DNS processing, host-cache state, and timeout behavior.

Do not use a successful localhost test as a remote proof. On many systems, localhost makes the client use a Unix socket rather than TCP, bypassing the interface, firewall, and route that the application depends on.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Match the client to the correct protocol and port

The classic mysql client must connect to a classic-protocol listener. Port 33060 is the default X Protocol port and is not interchangeable with the classic listener on 3306. MySQL release notes document ERROR 2013 during initial communication when a classic client was pointed at the X Protocol port; the two protocols initialize connections differently.

Check the application’s connection string, environment variables, and secret configuration for a stale port. A common migration mistake is copying an X Protocol endpoint into a library that speaks only the classic protocol, or copying a classic endpoint into an X DevAPI client that expects X Protocol. Correct the endpoint in the client configuration, then retest from the application host.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

When a proxy or router is involved, verify protocol support on both sides. The front end may listen on one port while selecting a different backend protocol. A raw TCP success to the proxy does not establish that the proxy can perform a valid backend handshake.

4. Check DNS behavior and account grants

Why DNS can appear as a handshake failure

For non-localhost TCP clients, MySQL may perform reverse and forward DNS lookups. A broken, slow, or inconsistent resolver can delay the initial exchange or prevent host validation. Compare a connection by the application’s hostname with a controlled test by IP, while keeping the same port and route. A difference points to name resolution or grant matching, not automatically to a MySQL password problem.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Repair the resolver path, or add a deliberate hosts-file entry where that is operationally appropriate. Treat a hosts-file workaround as a controlled change: keep the address current and document it so a later IP change does not silently break access.

Understand skip_name_resolve

Starting MySQL with skip_name_resolve disables DNS host-name lookups. This can remove resolver delays, but it changes how grants match clients: account rows in the grant tables must use IP addresses rather than host names. Enabling the option without converting the relevant Host values can turn a DNS problem into an access failure.

Before changing this setting, inventory the accounts used by the application and the source addresses they actually present. Apply the grant changes in a maintenance window, preserve a tested administrative path, and verify a new connection from the application network. Do not treat skip_name_resolve as a universal performance switch; it is a behavior change with an access-control consequence.

5. Inspect and clear host-cache blocks

MySQL tracks connection errors by source host in performance_schema.host_cache. Query that table for the client IP and review its validation state and error counters. The entries can reveal repeated interrupted handshakes, name-resolution failures, and other connection errors that are invisible from the client message alone.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

If a legitimate source has been blocked after repeated failed attempts, an administrator can clear the host cache with:

mysqladmin flush-hosts

Use administrative credentials and the documented SQL or administrative equivalent when that is preferable in your environment. Flush only after correcting the underlying interruption or misconfiguration; otherwise the same source will accumulate errors and become blocked again.

The current MySQL 9.7 reference documentation lists a default max_connect_errors value of 100. Raising that limit alone does not repair a dropped route, malformed traffic, failed DNS lookup, or wrong protocol. Treat the value as a protection threshold, not as a connectivity fix.

6. Tune connect_timeout only after the path works

If repeated TCP probes succeed and the server is healthy, but the initial packet is genuinely slow to arrive, inspect the effective connect_timeout. MySQL suggests trying 10 seconds or more for long-distance or slow links. Increase the value in a controlled, minimal change, then test the application again.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Record Aborted_connects before the change and compare it after representative connection attempts. A falling count supports the timeout hypothesis; an unchanged failure with a closed or filtered port means the timeout adjustment was irrelevant. Avoid setting very large values indiscriminately: each stalled connection can consume client, proxy, or server resources for longer, delaying failure detection and masking a network outage.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

7. Use server evidence to select the final fix

Review the error log

Match the client failure time to the MySQL error log. Look for bind failures, aborted handshakes, DNS-related messages, host blocking, protocol complaints, and restarts. The server timestamp and source address are especially useful when multiple applications share one database.

Check status counters

Inspect Aborted_connects and the Connection_errors_* status variables. These counters help distinguish failures caused by malformed or incomplete packets, host validation, authentication-stage issues, and resource or network conditions. Capture a baseline, make one change, and observe the counters again instead of changing several variables at once.

Use the general query log selectively

When enabled and appropriate for your security and performance requirements, the general query log can show whether a connection reaches the server far enough to be recorded. Enable diagnostic logging only for the shortest useful interval, protect credentials and personally identifiable data, and disable it after the test. A missing server-side record combined with a failed TCP probe points to the path before MySQL; a record with an aborted connection narrows the issue to server-side processing or the client’s early disconnect.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why MySQL works locally but fails remotely

Local and remote tests often exercise different transports. A local mysql command may use a Unix socket, while a remote application uses TCP. The local path can therefore bypass bind_address, host firewalls, cloud security groups, container port publishing, DNS, and proxy routing.

To reproduce the application’s conditions, specify the same hostname or IP, classic port, protocol, and authentication options from the remote runtime. If that test fails while a socket connection succeeds, inspect network exposure and listener configuration before changing users or passwords. If the remote TCP probe succeeds but the client still reports 2013, move to protocol pairing, DNS/grants, host cache, and timeout evidence.

Choose a remedy by failure layer and risk

Remedy Layer addressed Privilege needed Reversibility and risk
Correct hostname, port, or client protocol Endpoint or protocol Client or application owner Highly reversible; low risk when copied from the server’s effective configuration.
Start MySQL or correct port/bind_address Listener/service Server administrator Reversible, but exposing a new interface has security implications.
Allow the source through host firewall, security group, ACL, or container mapping Network path Network or infrastructure administrator Reversible; limit source ranges and destination ports.
Repair DNS or use a deliberate IP-based path Name resolution and grants DNS and database administrator Reversible, but stale address mappings can create outages.
Enable skip_name_resolve and convert grants to IP hosts DNS lookup behavior Database administrator Reversible, but incorrect Host values can lock out clients.
Run mysqladmin flush-hosts Host-cache block Database administrator Immediate and reversible in effect; the block returns if the cause remains.
Increase connect_timeout Slow initial response Configuration administrator, depending on deployment Reversible; excessive values keep stalled sessions waiting longer.
Raise max_connect_errors Host-cache threshold Database administrator Reversible, but it does not fix the network or protocol fault and can reduce protection.

A controlled recovery runbook

  1. Write down the failing client’s source network, destination name or IP, port, protocol, and timestamp.
  2. Confirm that mysqld is running and record its effective listening port and addresses.
  3. From the failing runtime, run nc -vz DB_HOST 3306 or an equivalent TCP probe.
  4. Resolve refusal or timeout results in the service, bind, firewall, route, security-group, tunnel, container, or proxy layer before touching MySQL timeout variables.
  5. Verify that the client library matches the listener protocol; never send a classic client to X Protocol port 33060.
  6. Compare hostname and IP behavior, then inspect DNS, skip_name_resolve, and account Host entries.
  7. Query performance_schema.host_cache for the source IP. If a legitimate host is blocked, flush the cache after correcting the repeated failure.
  8. Capture Aborted_connects, relevant Connection_errors_* values, and matching error-log entries.
  9. Only when reachability and protocol are proven, increase connect_timeout modestly—MySQL’s guidance is to try 10 seconds or more on slow or long-distance links—and retest.
  10. Revert temporary logging, hosts-file entries, firewall exceptions, or timeout changes that are no longer required, and document the permanent configuration.

Preventing another initial-handshake outage

  • Keep the application endpoint, classic port, and protocol in one documented configuration source.
  • Monitor listener availability and TCP reachability from the application network, not only from the database host.
  • Alert on rising Aborted_connects, Connection_errors_*, and host-cache error counters before a source is blocked.
  • Record firewall, security-group, container, tunnel, and proxy changes alongside database changes.
  • If using skip_name_resolve, maintain IP-based grants and a tested administrative account.
  • Test failover and proxy backend health; an accepting front-end socket does not guarantee a healthy MySQL backend.
  • Keep timeout changes proportional to measured latency so outages fail quickly without creating unnecessary connection buildup.

ERROR 2013 at the initial handshake is solved most reliably by locating the first broken layer. Prove the endpoint and TCP path, pair the right protocol with the right port, then investigate DNS, grants, host-cache state, and timing with server evidence. Configuration changes should confirm that diagnosis, not substitute for it.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.