# Postgres error codes

> Causes and fixes for the SQLSTATE errors apps hit most, with the PostgREST/supabase-js HTTP mapping.

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

## Error guides

- [08006: connection failure / server closed the connection unexpectedly](https://scribase.com/postgres-errors/08006)
- [08001: could not connect to server / connection refused](https://scribase.com/postgres-errors/08001)
- [0A000: feature not supported](https://scribase.com/postgres-errors/0a000)
- [21000: more than one row returned by a subquery used as an expression / ON CONFLICT DO UPDATE command cannot affect row a second time](https://scribase.com/postgres-errors/21000)
- [22001: value too long for type character varying(n)](https://scribase.com/postgres-errors/22001)
- [22003: integer out of range / numeric field overflow](https://scribase.com/postgres-errors/22003)
- [22007: invalid input syntax for type timestamp / date](https://scribase.com/postgres-errors/22007)
- [22008: date/time field value out of range](https://scribase.com/postgres-errors/22008)
- [22012: division by zero](https://scribase.com/postgres-errors/22012)
- [22P02: invalid input syntax for type uuid / integer](https://scribase.com/postgres-errors/22p02)
- [23502: null value in column "x" of relation "y" violates not-null constraint](https://scribase.com/postgres-errors/23502)
- [23503: insert or update on table "x" violates foreign key constraint "x_y_fkey"](https://scribase.com/postgres-errors/23503)
- [23505: duplicate key value violates unique constraint "x_pkey"](https://scribase.com/postgres-errors/23505)
- [23514: new row for relation "x" violates check constraint "y"](https://scribase.com/postgres-errors/23514)
- [23P01: conflicting key value violates exclusion constraint](https://scribase.com/postgres-errors/23p01)
- [25P02: current transaction is aborted, commands ignored until end of transaction block](https://scribase.com/postgres-errors/25p02)
- [25006: cannot execute INSERT in a read-only transaction](https://scribase.com/postgres-errors/25006)
- [28P01: password authentication failed for user "x"](https://scribase.com/postgres-errors/28p01)
- [28000: no pg_hba.conf entry for host / role "x" is not permitted to log in](https://scribase.com/postgres-errors/28000)
- [3D000: database "x" does not exist](https://scribase.com/postgres-errors/3d000)
- [3F000: schema "x" does not exist](https://scribase.com/postgres-errors/3f000)
- [40001: could not serialize access due to concurrent update](https://scribase.com/postgres-errors/40001)
- [40P01: deadlock detected](https://scribase.com/postgres-errors/40p01)
- [42501: permission denied for table x / new row violates row-level security policy for table "x"](https://scribase.com/postgres-errors/42501)
- [42601: syntax error at or near "x"](https://scribase.com/postgres-errors/42601)
- [42P01: relation "x" does not exist](https://scribase.com/postgres-errors/42p01)
- [42P07: relation "x" already exists](https://scribase.com/postgres-errors/42p07)
- [42P05: prepared statement "s0" already exists](https://scribase.com/postgres-errors/42p05)
- [26000: prepared statement "x" does not exist](https://scribase.com/postgres-errors/26000)
- [42703: column "x" does not exist](https://scribase.com/postgres-errors/42703)
- [42702: column reference "x" is ambiguous](https://scribase.com/postgres-errors/42702)
- [42704: type "x" does not exist / role "x" does not exist](https://scribase.com/postgres-errors/42704)
- [42710: policy "x" for table "y" already exists / role "x" already exists](https://scribase.com/postgres-errors/42710)
- [42804: column "x" is of type integer but expression is of type text](https://scribase.com/postgres-errors/42804)
- [42803: column "x" must appear in the GROUP BY clause or be used in an aggregate function](https://scribase.com/postgres-errors/42803)
- [42883: function x(unknown) does not exist](https://scribase.com/postgres-errors/42883)
- [42P10: there is no unique or exclusion constraint matching the ON CONFLICT specification](https://scribase.com/postgres-errors/42p10)
- [42P17: infinite recursion detected in policy for relation "x"](https://scribase.com/postgres-errors/42p17)
- [53300: sorry, too many clients already / remaining connection slots are reserved](https://scribase.com/postgres-errors/53300)
- [53100: could not extend file: No space left on device](https://scribase.com/postgres-errors/53100)
- [53200: out of memory](https://scribase.com/postgres-errors/53200)
- [54000: index row size exceeds btree version 4 maximum 2704 for index](https://scribase.com/postgres-errors/54000)
- [55P03: could not obtain lock on row in relation "x"](https://scribase.com/postgres-errors/55p03)
- [55000: object not in prerequisite state](https://scribase.com/postgres-errors/55000)
- [57014: canceling statement due to statement timeout](https://scribase.com/postgres-errors/57014)
- [57P01: terminating connection due to administrator command](https://scribase.com/postgres-errors/57p01)
- [P0001: raise_exception (a RAISE EXCEPTION in PL/pgSQL)](https://scribase.com/postgres-errors/p0001)
- [XX000: internal error](https://scribase.com/postgres-errors/xx000)