# "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.