'Code: 210. DB::NetException: Connection refused (localhost:9000)

unable to connect to the client,following is the error

root@abcC:~# clickhouse-server client ClickHouse client version
20.1.4.14 (official build). Connecting to localhost:9000 as user default.
**Code: 210. DB::NetException: Connection refused (localhost:9000)**


Solution 1:[1]

Try this command:

sudo service clickhouse-server restart

Solution 2:[2]

You can try 3 things:

  1. try to deletemy-clickhouse/user.d/allow_only_from_localhost.xml config. Now, the user default can connect from any ip (caution).

  2. check the tcp port with

clickhouse extract-from-config --config-file "$CLICKHOUSE_CONFIG" --key=tcp_port

by default it is 9000. Then try connecting to the correct tcp port

clickhouse-client --port 9000

ClickHouse client version 21.8.15.7.
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 21.8.15 revision 54449.

c6d6dd1623a5 :) 
  1. If you are using the docker image yandex/clickhouse-server, you can try to add my-clickhouse/config.d/docker_related_config.xml config.
<yandex>
     <!-- Listen wildcard address to allow accepting connections from other containers and host network. -->
    <listen_host>::</listen_host>
    <listen_host>0.0.0.0</listen_host>
    <listen_try>1</listen_try>

    <!--
    <logger>
        <console>1</console>
    </logger>
    -->
</yandex>

then in your .dockerfile :

FROM yandex/clickhouse-server:latest

COPY config.d/* /etc/clickhouse-server/config.d/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Adrian Mole
Solution 2