Supabase Error PGRST116: Multiple or Zero Rows for a Singular Request

Supabase error PGRST116 (Multiple or Zero Rows for a Singular Request) explained: what it means, why it happens, and how to fix it — with copy-paste code examples.

Error code PGRST116 Supabase Last verified 2026-08-19

Quick Answer

Use .maybeSingle() when 0-or-1 rows are expected. If that does not apply, add a unique filter such as .eq('id', value) before .single() — the full checklist is below.

Error Code

Error code: PGRST116
Official name: Multiple or Zero Rows for a Singular Request
Service: Supabase

What does this error mean?

More than 1 or no items were returned when requesting a singular response.

Common Causes

How to Fix

  1. Use .maybeSingle() when 0-or-1 rows are expected
  2. Add a unique filter such as .eq('id', value) before .single()
  3. Check error.code === 'PGRST116' and return null instead of throwing
  4. Only use .limit(1) together with deterministic ordering

Code Examples

maybeSingle for 0-or-1 rows javascript
const { data, error } = await supabase
  .from('profiles')
  .select('*')
  .eq('user_id', userId)
  .maybeSingle()

if (data === null) {
  // no profile yet - treat as a fresh user
  return createDefaultProfile(userId)
}

maybeSingle returns null for 0 rows and never raises PGRST116 for the empty case.

Catch PGRST116 explicitly javascript
const { data, error } = await supabase
  .from('orders')
  .select('*')
  .eq('id', orderId)
  .single()

if (error?.code === 'PGRST116') {
  return notFound('Order does not exist')
}

When you must use .single(), guard the 406 so a missing row maps to a 404 response.

Framework-Specific Fixes

supabase-js

Replace .single() with .maybeSingle() for optional rows; the result is null instead of a PGRST116 error.

const { data } = await supabase
  .from('profiles')
  .select('*')
  .eq('user_id', userId)
  .maybeSingle() // null when no row matches
supabase-python

The Python client surfaces the same PostgREST code; use maybe_single() for optional rows.

row = (
    supabase.table('profiles')
    .select('*')
    .eq('user_id', user_id)
    .maybe_single()
    .execute()
).data  # None when no row matches

You Might Also Like

Frequently Asked Questions

Why am I seeing Supabase error PGRST116?

Most often this happens when .single() called when the query returns 0 rows, or when query matched multiple rows while using .single().

How do I fix Supabase error PGRST116?

Use .maybeSingle() when 0-or-1 rows are expected.

Which frameworks have documented fixes for error PGRST116?

This page documents fixes for: supabase-js, supabase-python.

Official Sources

This page is based on the official Supabase documentation linked below and adds practical troubleshooting guidance on top.