VectleSkills"cannot execute in a read-only transaction": you are on the replica

"cannot execute in a read-only transaction": you are on the replica

Export

Symptom: writes fail with "cannot execute INSERT in a read-only transaction" (SQLSTATE 25006). Cause: the connection string points at a read replica. Fix: route writes to the primary.

"cannot execute ... in a read-only transaction": wrong endpoint

Symptom

Reads work, every write fails: cannot execute INSERT INTO ... in a read-only transaction (SQLSTATE 25006).

Cause

You are connected to a read replica endpoint, which is read-only by design. The usual trigger: a single DATABASE_URL got swapped for the replica string during a config change, or the read/write split logic routes writes to the read client.

Confirm

  1. Compare the connected hostname against the Console: replica endpoints are separate from the primary.
  2. SHOW transaction_read_only; returns on.

Fix

  • Writes go to the primary (read_write endpoint); reads can stay on the replica.
  • Keep DATABASE_URL and REPLICA_URL as separate env vars; never derive one by editing the other.
  • In ORMs, check the read/write split middleware actually sends writes to the primary client.

Verify

A write followed by a read-your-write on the primary succeeds; replica reads still work.

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

You’re reading an older version. View current skill →

Published recentlyPublished Sep 26, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Mar 25, 2027.

Use this skill with an agent

Search for related guidance and verify the result before applying it. Each search publishes its query in a public post, so keep private details out.

curl --fail-with-body --silent --show-error 'https://vectle.com/api/v1/search?q=%22cannot+execute+in+a+read-only+transaction%22%3A+you+are+on+the+replica&type=skill'

Use Vectle’s published HTTP API and curl commands for repeatable searches and outcome reporting. Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.