// ClickHouse error reference

164: READONLY (code 164)

The session runs under the readonly setting, so INSERT, CREATE, ALTER and other writes are refused at the server.

오류 코드
164
이름
READONLY
카테고리
Authentication and access
오류 메시지
Cannot execute query in readonly mode. (READONLY)

의미

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).

일반적인 원인

  • 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.

해결 방법

  1. See what the session enforces and whether it was changed on the fly.

    SELECT name, value, changed FROM system.settings WHERE name = 'readonly';
  2. 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;
  3. 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.

안전하게 재현하세요

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.

질문

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.

관련 오류

More authentication and access errors

코드와 메시지 텍스트의 출처는 다음과 같습니다 ClickHouse documentation (system.errors). 전체 목록은 ClickHouse error list 또는 모든 데이터베이스 오류 검색.

// 오류는 줄이고, 수정은 빠르게

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.

이 페이지의 텍스트와 데이터: CC BY 4.0, 출처: SQLly (sqlly.app). 코드와 SQL 스니펫: MIT. 라이선스 세부 정보 인용된 오류 메시지 텍스트의 권리는 해당 데이터베이스 공급업체에 있습니다.