Skip to main content
When a MySQL client cannot complete the handshake with a ClickHouse Cloud service, it does not show a ClickHouse error message. It reports that the connection was lost:
The message does not say why. Check four things: the MySQL interface is enabled for the service, the user name starts with mysql4 and the subdomain of the service, your IP address is in the IP access list, and the password of the user is stored as double_sha1_password.

How to read the message

  • The text in quotes is the step of the handshake at which the client lost the connection. Both 'reading authorization packet' and 'reading final connect information' mean that the connection was closed before the login completed.
  • The number after system error is an error code of the operating system of the client, so it differs between platforms. A connection reset by the peer is 54 on macOS and 104 on Linux.
  • The MariaDB client words the same error as Lost connection to server at ....
For comparison, this is a connection that works, for a service with the host name foobar.us-east1.aws.clickhouse.cloud:

  1. Is the MySQL interface enabled?

The MySQL interface is off until you enable it for the service. In the ClickHouse Cloud console, open Connect, choose MySQL in the Connect with list, and turn on the switch. This exposes port 3306 for the service, and the dialog shows the MySQL user name to use. See Enabling the MySQL interface on ClickHouse Cloud.

  1. Does the user name have the mysql4 prefix?

Every service has a built-in user mysql4<subdomain> with the same password as the default user, where <subdomain> is the first part of the host name of the service. Additional users for the MySQL interface are named mysql4<subdomain>_<name>. For the host name above, these are mysql4foobar and, for example, mysql4foobar_team1. The prefix tells ClickHouse Cloud which service a connection belongs to when the client does not send SNI information in its TLS handshake, and the mysql console client is such a client. A user name that does not follow this format leads to the error above, even if the same user works with clickhouse-client. See Creating multiple MySQL users in ClickHouse Cloud.

  1. Is your IP address in the IP access list?

The IP access list of the service filters the connections of the MySQL interface too. A connection from an address that is not on the list is closed. To check from the machine that runs the MySQL client, use the test from the IP access list page:
It prints Ok. if the address is allowed, and a connection reset error if it is not. Add the public address of the client to the list. For a hosted BI tool, add the addresses that its vendor publishes.

  1. Is the password stored as double_sha1_password?

The password of a user of the MySQL interface must be in double SHA1 format. With another type, for example sha256_password, the same user and password work in clickhouse-client, but the MySQL client fails, typically one step later in the handshake:
Check how the password is stored:
Set the password again with the right type. Replace <password> with a password of your own:
IDENTIFIED WITH without ADD replaces all authentication methods of the user, see the examples for ALTER USER. After this statement, the user can sign in only with this password, on every interface. If other applications use the same user with a different password or authentication method, change them at the same time, or leave that user as it is and create a separate user for the MySQL interface.

If the connection still fails

  • Make sure that the service is running and that your network allows outgoing connections to port 3306.
  • Connect from the same machine with clickhouse-client or curl to find out whether the problem is specific to the MySQL interface.
  • Contact ClickHouse support.