How to Fix MySQL Error 1836 (ER_READ_ONLY_MODE)
You get mysql error 1836 when a client tries to change data on a read-only server. You fix it by routing write requests to the primary database node. In the official MySQL error list, code 1836 maps to the ER_READ_ONLY_MODE symbol. It uses SQLSTATE HY000 and returns the message that the server is running in read-only mode. This state protects replica nodes and standby instances from unintended data changes. When an app or engineer sends a write query to a locked node, MySQL stops the action rig
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 get mysql error 1836 when a client tries to change data on a read-only server. You fix it by routing write requests to the primary database node.
In the official MySQL error list, code 1836 maps to the ER_READ_ONLY_MODE symbol. It uses SQLSTATE HY000 and returns the message that the server is running in read-only mode. This state protects replica nodes and standby instances from unintended data changes. When an app or engineer sends a write query to a locked node, MySQL stops the action right away.
What causes mysql error 1836 in your database
Several setup issues can trigger mysql error 1836 in a live system. The most common cause is a cluster failover that happened recently. During a failover, the old primary node steps down and becomes a read-only replica. If your app still points to the old host address, every write query will fail.
A second cause is a mistake in your app routing setup. Many teams split read and write traffic across different database endpoints. If a developer sends a write task to a reader endpoint, the replica rejects it. This also happens when a load balancer sends traffic to the wrong backend pool.
Maintenance work by your cloud host can also lock the database. Cloud providers often switch an instance to read-only mode during upgrades or backups. Disk space limits can cause the same behavior on managed database services. When storage fills up, the service blocks all writes to stop data corruption.
Finally, an admin might enable the super read-only mode on the server. Standard read-only mode still lets admin users make changes to tables. Super read-only mode blocks writes from every user, including root admins.
How to check and fix read-only mode safely
Start your check by finding out which node your client uses right now. Ask your database team which instance serves as the active primary node. Do not turn off read-only flags on a replica just to make an error stop. Writing data to a replica breaks replication and causes data drift across the cluster.
Read-Only Root Filesystem + MySQL Access Governance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
If your app hits a replica by mistake, update the host address in your app setup. Point write traffic to the cluster writer endpoint instead of a direct node IP. Using a writer DNS name helps your app follow the primary node during failovers. Restart your app connection pool if it holds old sessions open to the old primary.
If the actual primary node is stuck in read-only mode, check your cloud console first. Look for active maintenance events, storage alerts, or failed failover tasks. If disk space is full, add more storage before you enable writes again. Once the host is healthy, an admin can turn off the read-only state through the server settings.
How to prevent write errors on read replicas
You can avoid future outages by separating read and write roles for your team. Give engineers read-only database roles for daily checks and data queries. Reserve write roles for approved tasks that point only to the primary endpoint. This rule stops human errors before they reach a replica node.
Teams should also review how they handle sensitive data during support sessions. Data masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs in results. Combining clear role limits with query checks keeps both primary and replica nodes safe.
Check MySQL queries and results on the wire
MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.
Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.
Frequently asked questions
What does ER_READ_ONLY_MODE mean in MySQL?
ER_READ_ONLY_MODE is the official MySQL symbol for error code 1836 under SQLSTATE HY000. It means the server blocks data changes because it runs in read-only mode.
Why do admin users still get mysql error 1836?
Admin users see this error when the server has super read-only mode turned on. That setting blocks write queries from all users, even those with full admin rights.
Should I turn off read-only mode on a replica to fix the error?
No, you should never enable writes on a replica node to clear a client error. Instead, point your client or app to the primary writer node in your cluster.
Related guides
In this post