# Postgres error 25006: cannot execute INSERT in a read-only transaction

> A write was sent to a connection or transaction that only allows reads.

Source: https://scribase.com/postgres-errors/25006

SQLSTATE class: Invalid Transaction State. Over PostgREST/supabase-js this maps to HTTP 405.

## Causes

- Connecting to a read replica or a standby.
- A transaction started with SET TRANSACTION READ ONLY, or default_transaction_read_only is on for the role or database.
- A database switched to read-only after hitting a storage limit.

## Fixes

- Send writes to the primary connection string.
- Check show default_transaction_read_only; and the role settings.
- Free or add space if the database was put in read-only mode for size.

PostgREST answers 405 when a write reaches a read-only transaction, for example a POST to a function marked STABLE.