Connect to a ClickHouse cluster
You can connect to a ClickHouse cluster:
- via console clients, for example clickhouse-client;
- program code.
SSL connection is used for all methods.
When connecting, specify the port and address.
Connection ports
To connect to ClickHouse, use the following ports:
- 9440 — port for connecting via native interface (TCP);
- 8443 — port for connecting via HTTP interface.
Connection addresses
The connection address depends on where you are connecting from. You can choose an address based on one of the following scenarios:

Connecting to a cluster from a private subnet
If you are connecting to a cluster from a private subnet, use the private IP address.
To connect from another private subnet, first connect both private subnets to a cloud router.
You can view the connection address in the Control Panel.
Connecting to a cluster from the Internet
If you are connecting to a cluster from the Internet, use a public IP address. The private subnet must meet the requirements. If the subnet does not meet the requirements, prepare it for a public IP address connection.
You can view the connection address in the Control Panel.
View the connection address
- In the Control Panel, click Products in the top menu and select Managed Databases.
- Open the Active tab.
- Open the database cluster page → Connection tab.
- In the Connection addresses block, open the tab for the node group whose addresses you want to view.
Connect to a cluster
clickhouse-client
Python
Go
Node.js
Java
-
Create a
config.xmlconfiguration file:if [ "$USER" = "root" ]; thenCONFIG_DIR="/root/.clickhouse-client"elseCONFIG_DIR="/home/${USER}/.clickhouse-client"fimkdir -p ${CONFIG_DIR}cat > ${CONFIG_DIR}/config.xml << EOF<config><openSSL><client><caConfig>${CONFIG_DIR}/root.crt</caConfig><verificationMode>strict</verificationMode><invalidCertificateHandler><name>RejectCertificateHandler</name></invalidCertificateHandler></client></openSSL></config>EOF -
Download the root certificate and place it in the
~/.clickhouse-client/folder:wget https://storage.dbaas.selcloud.ru/CA.pem -O ~/.clickhouse-client/root.crtchmod 0600 ~/.clickhouse-client/root.crt -
Connect to the node:
clickhouse-client --host <host> \--secure \--user admin \--database <database_name> \--port <port> \--password <password>Specify:
<host>— node IP address; ;<database_name>— the database name. When connecting to the cluster for the first time, specify the default database —default. After the first connection, you can create new databases;<port>— connection port;<password>— the administrator user password. The password is set when creating the cluster. After creation, the password cannot be viewed in the Control Panel, but it can be changed.