9

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)**
lloiacono
  • 4,714
  • 2
  • 30
  • 46
Aneesh Babu
  • 91
  • 1
  • 2
  • 4
  • 3
    clickhouse is not started. check `service clickhouse-server status` – Denny Crane Feb 18 '20 at 15:55
  • 2
    try `clickhouse-client -h 127.0.0.1 --user default` also check `grep -r -E "listen|host_regexp||" /etc/clickhouse-server/` check your connection is allowed maybe localhost resolved as different ip – Slach Feb 19 '20 at 06:27
  • this is the error when executed SERVICE CLICKHOUSE-SERVER STATUS clickhouse-server.service - ClickHouse Server (analytic DBMS for big data) Loaded: loaded (/etc/systemd/system/clickhouse-server.service; enabled; vendo Active: activating (auto-restart) (Result: exit-code) since Thu 2020-02-20 17 Process: 9066 ExecStart=/usr/bin/clickhouse-server --config=/etc/clickhouse-se Main PID: 9066 (code=exited, status=70) Tasks: 0 Memory: 0B CPU: 0 CGroup: /system.slice/clickhouse-server.service – Aneesh Babu Feb 20 '20 at 17:40
  • clickhouse-server.service - ClickHouse Server (analytic DBMS for big data) Loaded: loaded (/etc/systemd/system/clickhouse-server.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Thu 2020-02-20 17:32:35 UTC; 7s ago Process: 9066 ExecStart=/usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-server.pid (code=e Main PID: 9066 (code=exited, status=70) – Aneesh Babu Feb 20 '20 at 17:41
  • 3
    check the log to find the reason of issue: *tail -64 /var/log/clickhouse-server/clickhouse-server.err.log* – vladimir Apr 26 '20 at 12:34

4 Answers4

1

Try this command:

sudo service clickhouse-server restart
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Pankaj
  • 11
  • 2
1

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/
Pierre Louis
  • 308
  • 2
  • 11
1

Try this command It's working for me. clickhouse-client --host 127.0.0.1 --password

0

Specify the config path when starting the server, that will show you what error you are getting, very comfortable way for debuging the issue:

clickhouse-server --config-file=/etc/clickhouse-server/config.xml 

or

sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-server/config.xml

Further read: https://clickhouse.com/docs/en/operations/troubleshooting/

S.Roshanth
  • 1,499
  • 3
  • 25
  • 36