# connect_timeout

> Seconds the server waits for a client to answer the handshake.

Source: https://sqlly.app/sql-configuration/mysql/connect-timeout
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).

**Default**

`10`

**Range**

2 to 31536000 seconds

**Restart needed**

No

**Default checked on**

MySQL 8.4 LTS

## What it does

mysqld waits this long for the client's connect packet after the TCP connection is accepted, then gives up with Bad handshake. Raising it helps clients that keep failing with 'Lost connection to MySQL server at waiting for initial communication packet', typically over slow or congested links.

## Default value

`10`. 10 seconds (MySQL 8.4).

## Check the current value

```
SHOW GLOBAL VARIABLES LIKE 'connect_timeout';

SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME
FROM performance_schema.variables_info
WHERE VARIABLE_NAME = 'connect_timeout';
```

## Change it

```
SET GLOBAL connect_timeout = 30;    -- until the next restart
SET PERSIST connect_timeout = 30;   -- now and after restarts
```

No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

## When to change it

When legitimate clients fail to get through the handshake on slow links, or while investigating a rise in Aborted_connects in SHOW GLOBAL STATUS.

## What can go wrong

Half-open handshakes each hold a thread until the timeout fires, so a large value lets a broken network or an aggressive connection flood tie up threads for minutes. The default ten seconds already covers most real links; fix the network before raising it much.

## Questions about connect_timeout

### What is the default value of connect_timeout in MySQL?

10. 10 seconds (MySQL 8.4).

### Does changing connect_timeout require a restart?

No. No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

### When should I change connect_timeout?

When legitimate clients fail to get through the handshake on slow links, or while investigating a rise in Aborted_connects in SHOW GLOBAL STATUS.

Back to all [MySQL settings](https://sqlly.app/sql-configuration/mysql), or check the [MySQL manual](https://dev.mysql.com/doc/refman/8.4/en/server-system-variables.html) for every option.

## Related MySQL settings

- [`max_connect_errors` Failed connection attempts from one host before it is blocked.](https://sqlly.app/sql-configuration/mysql/max-connect-errors)
- [`back_log` Depth of the listen queue for incoming TCP connections.](https://sqlly.app/sql-configuration/mysql/back-log)
- [`net_read_timeout` Seconds the server waits for more data from a client before aborting the read.](https://sqlly.app/sql-configuration/mysql/net-read-timeout)

## Related on SQLly

- [Diagnosing a slow SQL query Performance guide](https://sqlly.app/sql-performance/slow-query)
