How to Configure n8n ClickHouse Connect
You set up an n8n clickhouse connect workflow by pairing an n8n tool with a scoped ClickHouse user. First, you create a dedicated database account and store those login details inside n8n. Many teams hurry this step and reuse an admin account for their workflows. Broad database permissions create high risk when automated jobs or AI agents run queries. A single bad query can expose private columns or overload your cluster. How the native n8n clickhouse connect setup works ClickHouse manages us
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up an n8n clickhouse connect workflow by pairing an n8n tool with a scoped ClickHouse user. First, you create a dedicated database account and store those login details inside n8n. Many teams hurry this step and reuse an admin account for their workflows. Broad database permissions create high risk when automated jobs or AI agents run queries. A single bad query can expose private columns or overload your cluster.
How the native n8n clickhouse connect setup works
ClickHouse manages users, roles, row policies, settings profiles, and quotas as SQL access entities. To use SQL access control, an admin turns on the server storage directory setting. An admin also needs a user account with access management rights turned on. That admin can then run a user creation statement for the n8n workflow. Remember that a ClickHouse user can only grant privileges that they already hold.
During user creation, you define how the account logs in and which hosts can reach it. You also assign default roles and specific user settings for the n8n job. On the n8n side, workflows and AI agents need a way to send queries. The n8n AI Agent node pairs a chat model with one or more tool sub-nodes. The agent then decides which tool to call in order to finish a task.
Older n8n versions had a dedicated SQL Agent, which only supported MySQL, SQLite, and Postgres. In recent n8n releases, all AI Agent nodes operate as a Tools Agent. To query ClickHouse from an agent, teams attach an HTTP Request Tool or Custom Code Tool. Teams can also use a Call n8n Workflow Tool or an MCP server tool. The chosen tool sends the SQL request to ClickHouse using the stored database login.
Using ClickHouse column grants to limit data exposure
Before you let an n8n workflow query your tables, you should restrict its read privileges. ClickHouse lets admins grant read rights on specific columns rather than whole tables. When you grant access to two specific columns, the n8n user can query only those fields. Any query that asks for a third, ungranted column will fail right away.
This rule also blocks wildcard queries that try to read every column at once. A wildcard select returns no data unless the table holds only the granted columns. Recent ClickHouse versions also let admins grant read rights using a table name prefix. A trailing asterisk on a table name grants access to all matching tables. These native controls help teams keep basic workflow jobs inside clear boundaries.
ClickHouse Access Management + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native roles solve and what they leave open
Native ClickHouse roles and column grants decide who can log in and which fields are visible. They stop an n8n workflow from reading restricted tables or dropping data when configured right. Still, static database grants cannot inspect what individual statements do while they run in flight. Once a user has permission on a column, every matching row value comes back raw.
If an allowed text column holds emails, phone numbers, or card numbers, n8n receives them. When an AI agent runs the tool, those raw values pass straight into the model prompt. Static database credentials also sit saved inside the n8n app store for any workflow run. Also, database logs show the shared n8n user rather than which workflow triggered the query. Teams also lack a step to pause and approve risky queries before ClickHouse runs them.
Add runtime guardrails and masking beside ClickHouse
Database grants and network rules control who can reach ClickHouse. Even so, an allowed client or agent can send an alter mutation that deletes rows or read raw personal data. In practice, hoop.dev runs beside the server as a sidecar for your ClickHouse and checks native TCP queries with no change to your drivers.
With hoop.dev ClickHouse support, guardrails refuse banned queries before they run, and data masking rewrites matched string columns in results. The audit trail logs which entity types were masked and how many without storing raw values. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Can the built-in n8n SQL Agent connect to ClickHouse directly?
No, the older n8n SQL Agent is deprecated and only supports Postgres, MySQL, and SQLite. Today, you use the standard AI Agent node and attach an HTTP, code, or workflow tool.
Why do wildcard queries fail after setting ClickHouse column grants?
ClickHouse blocks wildcard select queries when a user only has grants on specific columns. The query only works if the user has rights on every column in that table by default.
How do you limit where the n8n ClickHouse user logs in from?
When you create the user in ClickHouse, you can define allowed client hosts in the statement. This restricts login attempts so they only succeed from your n8n server address.
Related guides
In this post