
Step by Step Guide to solve n8n MySQL node connection timeout
Who this is for: Developers and DevOps engineers running n8n workflows that need reliable MySQL connectivity in Docker, Kubernetes, or self‑hosted environments. We cover this in detail in the n8n Node Specific Errors Guide.
Quick Diagnosis: Fix the timeout in 5 minutes
- Verify you can reach MySQL from the n8n host (
nc -z <host> 3306). - In the MySQL node, set Connect Timeout →
30000ms (or higher). - Increase MySQL server variables
wait_timeoutandinteractive_timeoutto ≥ 300 seconds. - If using SSL, add the correct
ca.pem/cert.pemfiles and enable TLS 1.2. - Restart the workflow – the node should now connect without timing out.
1. What the “Connection timeout” error really means
If you encounter any n8n smtp node send failure resolve them before continuing with the setup.
| Symptom | Typical n8n log line |
|---|---|
| Error: MySQL node connection timeout after 10000 ms | 2024-09-01 12:34:56 – error – MySQL node connection timeout after 10000 ms |
| Error: ECONNREFUSED | … – error – connect ECONNREFUSED 10.0.2.5:3306 |
| Error: ER_ACCESS_DENIED_ERROR | … – error – ER_ACCESS_DENIED_ERROR: Access denied for user |
| Underlying cause |
|---|
|
EEFA note: In production, a timeout often masks a deeper network policy (e.g., security groups, VPC peering) that silently drops packets after a few seconds. Always confirm connectivity before tweaking n8n settings.
2. Common root‑causes for MySQL node timeouts in n8n
If you encounter any n8n excel node file corruption resolve them before continuing with the setup.
| Category | Typical trigger |
|---|---|
| Network path | VPC firewall, Docker bridge, VPN split‑tunnel |
| MySQL server config | wait_timeout < connect_timeout |
| n8n node config | Default Connect Timeout = 10 000 ms (insufficient for high latency) |
| TLS/SSL mismatch | Missing CA bundle or outdated TLS version |
| Connection pooling | Reusing stale sockets after a server restart |
| Quick verification |
|---|
|
3. Step‑by‑step: Verify raw connectivity
*Confirm the network and MySQL handshake work before changing any n8n settings.*
We cover this in detail in the n8n Node Specific Errors Guide
# Test TCP reachability nc -zvw5 mysql.example.com 3306
Expected output:
Connection to mysql.example.com 3306 port [tcp/mysql] succeeded!
# Test MySQL handshake without authentication mysql -h mysql.example.com -P 3306 -u dummy -pdummy --connect-timeout=5 -e "SELECT 1;"
You should see 1 or a clear authentication error—not a timeout. If either command fails, fix firewalls, VPC routes, or DNS first.
4. Configure the MySQL node for longer timeouts
If you encounter any n8n wait node timeout resolve them before continuing.
Purpose: Extend the socket‑creation window so high‑latency or busy networks can complete the handshake.
4.1 Set the timeout in the node UI
- Open the workflow → edit the MySQL node.
- Click Advanced Settings → enable Custom Timeout.
- Set Connect Timeout (ms) to a value that exceeds your worst‑case latency (e.g.,
30000). - (Optional) Enable Force New Connection to avoid re‑using stale sockets.
4.2 JSON representation (for reference)
{
"host": "mysql.example.com",
"port": 3306,
"user": "n8n_user",
"password": "••••••"
}
{
"connectTimeout": 30000,
"forceNewConnection": true
}
EEFA tip: Avoid setting the timeout arbitrarily high (> 2 min) in production; it masks genuine network failures and can tie up worker threads.
5. Tune MySQL server variables
Purpose: Ensure the server does not close idle connections before n8n finishes its handshake.
5.1 Inspect current values
SHOW VARIABLES LIKE 'wait_timeout'; SHOW VARIABLES LIKE 'interactive_timeout'; SHOW VARIABLES LIKE 'connect_timeout';
5.2 Raise them to safe defaults (e.g., 300 seconds)
SET GLOBAL wait_timeout = 300; SET GLOBAL interactive_timeout = 300; SET GLOBAL connect_timeout = 10;
5.3 Persist the changes in my.cnf
[mysqld] wait_timeout = 300 interactive_timeout = 300 connect_timeout = 10
Restart MySQL to apply:
systemctl restart mysqld # or `service mysql restart`
EEFA warning: Raising
wait_timeouttoo much can keep idle connections open, consuming resources. MonitorSHOW PROCESSLIST;after the change.
6. SSL/TLS considerations (if your MySQL endpoint requires encryption)
| Setting in n8n node | Required file | Common pitfalls |
|---|---|---|
| Use TLS | ca.pem (CA bundle) |
Wrong CA → handshake fails → timeout |
| Client Cert | client-cert.pem |
Expired cert → connection reset |
| Client Key | client-key.pem |
Permissions too restrictive (600) → node can’t read |
6.1 JSON snippet for TLS configuration
{
"ssl": {
"ca": "/secrets/mysql/ca.pem",
"cert": "/secrets/mysql/client-cert.pem",
"key": "/secrets/mysql/client-key.pem"
}
}
{
"ssl": {
"rejectUnauthorized": true
}
}
6.2 Verify the TLS handshake manually
openssl s_client -connect mysql.example.com:3306 -CAfile /secrets/mysql/ca.pem
If the handshake stalls, the timeout will reappear – fix the certificate chain first.
7. Debugging with n8n logs
Enable debug logging in ~/.n8n/config:
[logging] level = "debug"
Watch the logs while the workflow runs:
docker logs -f n8n_container # Look for lines containing “MySQL node” and “timeout”
Typical useful output:
2024-09-01 12:34:56 - debug - MySQL node: establishing TCP connection to mysql.example.com:3306 2024-09-01 12:34:56 - error - MySQL node connection timeout after 30000 ms
If you see “TLS handshake timeout”, revisit the SSL/TLS step.
8. Checklist – Resolve MySQL node timeout
- Network reachable –
ncsucceeds from n8n host. - MySQL node timeout set ≥ 30 000 ms (or appropriate for latency).
- Server variables
wait_timeout&interactive_timeout≥ 300 s. - SSL files present, correct permissions, and match server config.
- Force New Connection enabled if using connection pooling.
- n8n logs show successful “connected” message, not “timeout”.
9. Frequently asked questions
| Question | Answer |
|---|---|
| Why does increasing the node timeout not help? | The TCP packets never reach the MySQL host (firewall/VPC). Fix network first. |
| Can I set the timeout per workflow instead of per node? | No. n8n’s MySQL node only respects the **Connect Timeout** field; workflow‑level timeouts affect the whole execution, not socket creation. |
| Is there a way to auto‑retry on timeout? | Wrap the MySQL node in an **IF** block with a **Retry** node (set retries = 3, delay = 5 s). |
My server uses max_allowed_packet=64M; does that affect timeout? |
Only if your query exceeds the packet size – you’ll get “Packet too large” instead of a timeout. |
Conclusion
A MySQL connection timeout in n8n is almost always a network or server‑configuration issue, not a bug in the node itself. By confirming raw connectivity, extending the node’s **Connect Timeout**, and aligning MySQL’s wait_timeout/interactive_timeout with your workflow latency, you eliminate the most common failure points. When TLS is required, ensure the full certificate chain is available and correctly referenced. Following the checklist above guarantees a robust, production‑ready MySQL integration that respects both security and performance constraints.



