---
name: clickhouse-install-auth
description: |-
  Install @clickhouse/client and configure authentication to ClickHouse Cloud
  or self-hosted. Use when setting up a new ClickHouse project, configuring
  connection strings, or initializing the official Node.js or Python client.
  Trigger with "install clickhouse", "setup clickhouse client", "clickhouse
  auth", "connect to clickhouse", "clickhouse credentials".
allowed-tools: Read, Write, Bash(npm:*), Bash(pnpm:*), Bash(pip:*)
version: 1.7.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
tags:
  - saas
  - database
  - analytics
  - clickhouse
  - olap
compatibility: Designed for Claude Code
title: clickhouse-install-auth
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/clickhouse-install-auth
last_updated: 2026-10-07T06:06:28.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/connection-reference.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-install-auth/references/connection-reference.md), [references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-install-auth/references/implementation.md).
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/clickhouse-install-auth`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/clickhouse-install-auth`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jeremylongshore/tons-of-skills-marketplace/clickhouse-install-auth) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/clickhouse-install-auth`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/clickhouse-install-auth --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/clickhouse-install-auth --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# ClickHouse Install & Auth

## Overview

Set up the official ClickHouse client for Node.js or Python and configure
authentication to ClickHouse Cloud or a self-hosted instance. The workflow
below is the high-level path; each step links to a full walkthrough with
complete code in [references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-install-auth/references/implementation.md).

## Prerequisites

- Node.js 18+ or Python 3.8+
- A running ClickHouse instance (Cloud or self-hosted)
- Connection credentials (host, port, user, password)

## Instructions

Follow these five steps. Read the current project for an existing `.env` before
writing one; write credentials to `.env` (never commit it).

1. **Install the official client.** Node.js uses the HTTP-based
   `@clickhouse/client`; Python uses `clickhouse-connect`.

   ```bash
   npm install @clickhouse/client   # Node.js
   pip install clickhouse-connect   # Python
   ```

2. **Configure environment variables.** Put host, user, and password in `.env`
   and add it to `.gitignore`. Cloud hosts use port `8443` (HTTPS); self-hosted
   uses `8123` (HTTP).

3. **Create the client.** Pass `url`, `username`, and `password` to
   `createClient()` (Node.js) or `get_client()` (Python). Cloud requires TLS —
   supply an `https://` URL and the client handles it.

   ```typescript
   import { createClient } from '@clickhouse/client';
   const client = createClient({
     url: process.env.CLICKHOUSE_HOST,
     username: process.env.CLICKHOUSE_USER,
     password: process.env.CLICKHOUSE_PASSWORD,
   });
   ```

4. **Verify the connection** with `client.ping()` plus a `SELECT version()`
   probe.

5. **Python alternative** — same shape via `clickhouse_connect.get_client(...)`
   with `secure=True` for Cloud.

Full code for every step (Cloud + self-hosted variants, the verify routine,
and the Python client): [references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-install-auth/references/implementation.md).
Every `createClient()` option and a Cloud-vs-self-hosted comparison:
[references/connection-reference.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-install-auth/references/connection-reference.md).

## Output

After completing the workflow you have:

- The official client installed (`@clickhouse/client` or `clickhouse-connect`).
- A `.env` holding `CLICKHOUSE_HOST` / `CLICKHOUSE_USER` / `CLICKHOUSE_PASSWORD`
  (gitignored).
- An initialized client module that reads those variables.
- A successful `ping()` returning `success: true` and a `SELECT version()`
  probe printing the server version and uptime — proof the connection and auth
  both work.

## Error Handling

| Error | Cause | Solution |
|-------|-------|----------|
| `ECONNREFUSED` | Server not running | Check host/port, verify ClickHouse is up |
| `Authentication failed` | Wrong user/password | Verify credentials in ClickHouse users.xml or Cloud console |
| `CERTIFICATE_VERIFY_FAILED` | TLS mismatch | Use `https://` for Cloud, check CA certs for self-hosted |
| `TIMEOUT` | Network/firewall | Check IP allowlists in Cloud console, firewall rules |
| `Database not found` | Wrong database name | Run `SHOW DATABASES` to list available databases |

## Examples

**Connect to ClickHouse Cloud (Node.js).** With `.env` populated, create the
client against the `https://…:8443` host and verify:

```typescript
const alive = await client.ping();        // { success: true }
const rs = await client.query({
  query: 'SELECT version() AS ver',
  format: 'JSONEachRow',
});
console.log((await rs.json())[0].ver);    // e.g. "24.8.1"
```

**Connect to a local self-hosted instance (no TLS).** Point at the HTTP
interface on `8123` with an empty password:

```typescript
const localClient = createClient({
  url: 'http://localhost:8123',
  username: 'default',
  password: '',
});
```

The full Cloud + self-hosted + Python set is in
[references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-install-auth/references/implementation.md).

## Resources

- [Official Node.js Client](https://clickhouse.com/docs/integrations/javascript)
- [Official Python Client](https://clickhouse.com/docs/integrations/python)
- [ClickHouse Cloud Quick Start](https://clickhouse.com/docs/cloud/get-started)
- [HTTP Interface Reference](https://clickhouse.com/docs/interfaces/http)

## Next Steps

Proceed to `clickhouse-hello-world` to create your first table and run an
insert-and-select round trip against the connection you just verified.
