The ClickHouse connection timeout sets how long a client (e.g., clickhouse_fdw in PostgreSQL) waits to establish a connection before aborting.
Slow networks, VPN hops, or overloaded ClickHouse nodes can delay hand-shakes. Raising the timeout prevents false failures, while lowering it surfaces real issues quickly.
The native clickhouse-client
defaults to 10 000 ms (10 s). Most drivers, including clickhouse_fdw
and the HTTP interface, inherit the same default unless overridden.
Pass connect_timeout
in the OPTIONS
clause. The value is in seconds.
Use ALTER SERVER
to replace the option without dropping objects. Afterwards, reconnect sessions or run DISCARD ALL
.
Query pg_foreign_server
or run \des+
in psql
. Look for the connect_timeout
key.
• Native client: --connect_timeout
• https: add timeout=5
URL param
• JDBC: socket_timeout=5000
(ms)
• Keep timeouts symmetrical across read & write paths.
• Log failed attempts with duration to tune later.
• Combine with statement_timeout
in PostgreSQL to guard long-running queries.
No. It only impacts future connection attempts. Cancel and rerun active queries if you need the new value.
Yes. Create multiple foreign servers (e.g., ch_fast
, ch_slow
) with different connect_timeout
values and grant usage selectively.
ClickHouse itself imposes no hard cap, but values above typical TCP keep-alive (2 min) rarely help. Start at 10-30 s and adjust based on logs.