164: READONLY (code 164)
The session runs under the readonly setting, so INSERT, CREATE, ALTER and other writes are refused at the server.
- Error code
164- Name
READONLY- Category
- Authentication and access
What it means
READONLY (164) means the session's readonly setting blocks data changes: readonly = 1 allows reads only, so SET is blocked too; readonly = 2 allows reads and SET but still blocks data changes. The value comes from the user's profile or the connection string, not from the table; a table refusing writes is TABLE_IS_READ_ONLY (242).
Common causes
- The user's profile sets readonly = 1 or 2, common for dashboards and the HTTP interface.
- The connection string or driver appends readonly=1 and the application then sends writes.
- A proxy or managed service hands out a readonly profile the user never asked for.
Find the cause
`system.settings` for the session value, `SHOW GRANTS FOR app_user` and `system.users` for the profile, and the server's users.xml or access-control storage for where readonly is set.
How to fix it
-
See what the session enforces and whether it was changed on the fly.
SELECT name, value, changed FROM system.settings WHERE name = 'readonly';
-
Ask an administrator to move the user into a writable profile; do not try to escape the restriction.
ALTER USER app_user SETTINGS PROFILE default;
-
Split workloads: keep dashboards on their readonly user and run writes as a separate read-write user.
GRANT SELECT ON my_db.* TO dashboard_ro;
Other ways to handle it
ACCESS_DENIED (497) fails one statement for missing grants; 164 blocks all writes for the session. A readonly = 1 session that tries SET gets 164 (Cannot modify 'max_threads' setting in readonly mode); a readonly = 2 session may SET other settings, but changing readonly itself also returns 164.
Reproduce it safely
The same INSERT succeeds for an unrestricted user, which proves the block is the session profile, not the table.
clickhouse-client --setting readonly=1, then INSERT INTO scratch_f VALUES (1) returns 164; the same INSERT as an unrestricted user succeeds.
Questions
What is the difference between readonly 1 and 2?
readonly = 1 blocks data changes and SET; readonly = 2 allows SET but still blocks data changes. Remove the managed-service sentence unless it is sourced.
Is this the same as a table in read-only mode?
No. 164 is the session setting, 242 TABLE_IS_READ_ONLY is a per-table state. The message and code tell you which one you hit.
Related errors
More authentication and access errors
The code and message text are from the ClickHouse documentation (system.errors). Browse the full ClickHouse error list or search every database error.
Work on ClickHouse in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for ClickHouse and the other databases you use.
Text and data on this page: CC BY 4.0, credit SQLly (sqlly.app). Code and SQL snippets: MIT. License details Quoted error message text belongs to its database vendor. View as Markdown