Guide · Supabase
PGRST116: "Cannot coerce the result to a single JSON object" in Supabase
How this guide was made: Written with AI assistance and checked against the sources linked on this page.
Updated
Short answer: PGRST116 "Cannot coerce the result to a single JSON object" (older versions: "JSON object requested, multiple (or no) rows returned") means your query asked for one object and the database gave back zero rows or more than one. It comes from .single(), which needs exactly one row. Check what your filter matches, switch to .maybeSingle() when zero rows is a valid result, narrow the filter or add .limit(1) when several rows match, and check Row Level Security. The table of causes shows where to start.
Verdict
| Question | Answer |
|---|---|
| Can I fix it myself? | Yes, if you can edit the query and open the Supabase SQL Editor. Run the same filter by hand to count the rows it matches, then use .maybeSingle() when zero rows is a normal result, narrow the filter or add .limit(1) when several rows match, and check that a SELECT policy exists for the role that runs the query. |
| How serious is it? | The request fails with HTTP 406 and your code gets an error instead of the row, so the page or action that needed that row breaks. It can work for you and fail for a signed-out visitor, because Row Level Security applies by role. |
| What does a fix cost? | Free if you follow the steps below. If you want it fixed for you, our AI agent fixes it in your code (see pricing) and re-checks your live app. |
What the error looks like
PostgREST, the API layer under Supabase's data API, answers with HTTP 406 and a JSON body that has four fields: code, message, details and hint. This is the shape for the zero-row case in current PostgREST versions:
{
"code": "PGRST116",
"message": "Cannot coerce the result to a single JSON object",
"details": "The result contains 0 rows",
"hint": null
}
These are the forms you can meet:
| What you see | Meaning |
|---|---|
Cannot coerce the result to a single JSON object, details The result contains 0 rows | The filter matched no row, or Row Level Security hid it |
Cannot coerce the result to a single JSON object, details with a row count above 1 | The filter matched more than one row |
JSON object requested, multiple (or no) rows returned | The older wording of the same PGRST116 error |
details Results contain 2 rows, application/vnd.pgrst.object+json requires 1 row | The supabase-js check for .maybeSingle() when a read matches several rows (the number is the row count) |
| HTTP 406 in the browser's Network tab | The status PostgREST gives for PGRST116 |
Log the whole error object, not only the message. The details line is what tells you zero rows from several:
const { data, error } = await supabase
.from('profiles')
.select('*')
.eq('id', userId)
.single()
if (error) {
console.error({ code: error.code, message: error.message, details: error.details })
}
What it means
Supabase's data API is PostgREST. When your code calls .single(), the request asks PostgREST for a single object instead of an array. PostgREST's docs describe it as the Accept: application/vnd.pgrst.object+json header. When a singular response is requested but no entries are found, "the server responds with an error message" and the "406 Not Acceptable status code rather than the usual empty array and 200 status". PostgREST's error table describes PGRST116 as "More than 1 or no items where returned when requesting a singular response."
The message text has changed between PostgREST versions. A PostgREST pull request titled "fix: clarify PGRST116 error message" changed "JSON object requested, multiple (or no) rows returned" to "Cannot coerce the result to a single JSON object". The changelog lists it in 13.0.0 (8 May 2025) as "Clarify Accept: vnd.pgrst.object error message". Both are the same PGRST116 error, and the fix is the same.
The Supabase reference for .single() says the query result must be one row, "otherwise this returns an error". Its example adds .limit(1).
Which cause is it?
| Cause | How to tell | Fix |
|---|---|---|
| The filter matches no row | details reads "The result contains 0 rows". The same query in the SQL Editor returns nothing | Fix the filter value or the table, or use .maybeSingle() if no row is a normal outcome |
| Row Level Security hides the row | The row exists in the SQL Editor, but the app gets 0 rows. The request may run as anon because the user is not signed in | Sign the user in before the query, or add a SELECT policy for the role that runs it |
An insert or update ends in .select().single() | The write seems to work, but the call returns PGRST116 | Add a SELECT policy for the table, and check that the filter on an update matches one row |
| The row is not there yet | The query runs right after sign-up or right after an insert that another process makes | Wait for the row, retry, or use .maybeSingle() and handle the empty result |
| The filter matches more than one row | details gives a row count above 1 | Filter on a column that is unique, or add .limit(1) |
| The app points at another project | The SQL Editor shows the row, but in a different Supabase project than the one your app uses | Compare the project URL in your live environment variables |
The filter matches no row
.single() fails on zero rows just as it does on several.
- Copy the table name, the column and the value from your code.
- In the Supabase SQL Editor, run the same filter by hand. This is a read, so it changes nothing:
select * from public.profiles where id = '<the value your code sent>';
- If it returns nothing, the row does not exist yet or the value is wrong. Check for a typo, a different table, or a query that runs before the row is created.
- If no row is a normal outcome (for example, "does this user have a profile yet?"), use
.maybeSingle(). The Supabase reference says the result must be zero or one row:
const { data, error } = await supabase
.from('characters')
.select()
.eq('name', 'Katniss')
.maybeSingle()
- Handle
databeing empty in your code before you read a property from it:
if (error) {
console.error(error)
return
}
if (!data) {
// no matching row: show an empty state or create the row
}
In the supabase-js source, .maybeSingle() clears the error and returns data as null when the details contain "0 rows". If a read matches two or more rows, .maybeSingle() still returns PGRST116, so it does not hide a too-wide filter.
Row Level Security hides the row
Supabase's Row Level Security guide says: "Think of a policy as adding a WHERE clause to every query." Because a policy works like a WHERE clause, we expect a row it hides to show up as fewer matching rows, not as an error. Your query then returns 0 rows and .single() raises PGRST116. The guide also says: "Once RLS is enabled, no data is accessible through the API when using a publishable key, until you create policies."
Supabase maps each request to a role: anon for "an unauthenticated request (the user is not signed in)" and authenticated for an authenticated request. Your own signed-in session can read a row that a signed-out visitor cannot.
- In the SQL Editor, list the policies on the table. This is a read:
select policyname, cmd, roles, qual
from pg_policies
where schemaname = 'public' and tablename = 'profiles';
The view's columns are the policy name, the command type the policy applies to, the roles it applies to, and the expression added to the security barrier qualifications for queries.
- Check that a SELECT policy exists for the role that runs your query, and that its
usingexpression is true for that row. - If the query runs before the user signs in, move it after sign-in, or add a policy that includes
anonif signed-out visitors should read it. - If the table has RLS on and no SELECT policy for signed-in users, add one. This example follows the form in Supabase's guide, where a user reads rows whose
user_idmatches their own id. Adapt the table and column names:
create policy "Users can read their own profile"
on public.profiles
for select
to authenticated
using ( (select auth.uid()) = id );
- Run the query again as the same kind of user, signed in or signed out.
An insert or update that ends in .select().single()
Chaining .select().single() after .insert() or .update() asks the database to return the written row, and .single() then needs exactly one row back. Supabase's guide says: "To perform an UPDATE operation, a corresponding SELECT policy is required." Without a SELECT policy we expect the returned row set to be empty, and then .single() raises PGRST116.
- Add a SELECT policy for the table, as above.
- For an update, read the target row first so you know the filter matches one row. The select changes nothing:
select id, updated_at from public.profiles where id = '<the id your update uses>';
- Scope the update to that id (
.eq('id', value)) and not to a wide filter, so it touches one row. - If the write itself is the thing you need, and you do not use the returned row, drop
.select().single().
The filter matches more than one row
.single() also fails when two or more rows match. The Supabase reference shows .limit(1) as the way to keep the result to one row:
const { data, error } = await supabase
.from('characters')
.select('name')
.limit(1)
.single()
- Read the
detailsline. If it gives a count above 1, your filter is too wide. - In the SQL Editor, count what the filter matches:
select count(*) from public.profiles where email = 'someone@example.com';
- If the column should be unique, find the duplicates before you change anything. This read lists each repeated value with the ids behind it:
select email, count(*) as copies, array_agg(id) as ids
from public.profiles
group by email
having count(*) > 1;
- Decide which row to keep. Take a backup first. Then check what points at the extra row before you delete it (our suggestion: look for foreign keys that reference this table, because some deletes also remove child rows). Select the row to confirm it is the one you mean:
select * from public.profiles where id = '<id of the extra row>';
Then remove the extras one at a time by id, never with a wide filter:
delete from public.profiles where id = '<id of the extra row>' returning *;
- A unique constraint prevents new duplicates. It fails while duplicates exist, so add it only after the clean-up. See the duplicate key guide if you add one and it fails.
- Filter on the primary key (
.eq('id', value)) when you want one specific row. - Use
.limit(1)only when any one of the matching rows is acceptable. Our suggestion: add an.order(...)so the same row comes back each time:
const { data, error } = await supabase
.from('profiles')
.select('*')
.eq('email', email)
.order('created_at', { ascending: false })
.limit(1)
.maybeSingle()
The row is not there yet
One case to check is a profile row that a trigger creates after sign-up. If your app reads it in the same moment, the row may not exist yet, and .single() raises PGRST116 even though the row appears a moment later in the SQL Editor.
- Run the filter in the SQL Editor a few seconds after the failure. If the row is there now, timing is the cause.
- Use
.maybeSingle()and treat an empty result as "not ready", then retry once or twice, or wait for the sign-in event before you read. - Do not create the row from the app and from the trigger at the same time, because that can produce the duplicates described above.
How do I check it's fixed?
- Run the exact request again. It returns
dataas one object anderrorisnull, ordataisnullwith no error when you use.maybeSingle()on an empty result. - Run it once signed in and once signed out, if your app serves both.
- Run the same filter in the SQL Editor and confirm it returns the number of rows your code expects (one, or zero for
.maybeSingle()). - Check the browser Network tab: the response status is no longer 406.
- For an update, confirm that the row changed and that no other row did.
FAQ
What does PGRST116 mean?
It is a PostgREST error code. PostgREST's error table lists it with HTTP status 406 and the description "More than 1 or no items where returned when requesting a singular response." Supabase's data API runs on PostgREST, so Supabase apps show it.
Is "JSON object requested, multiple (or no) rows returned" a different error?
No. It is the older wording of the same PGRST116 error. PostgREST 13.0.0 changed the message to "Cannot coerce the result to a single JSON object". The code stays PGRST116, and the fix is the same.
Should I use .maybeSingle() or .limit(1).single()?
They solve different problems. .maybeSingle() accepts zero or one row, so it fits "does this row exist?". .limit(1).single() keeps the result to one row when several match, but still fails on zero rows. .limit(1).maybeSingle() covers both.
Why does it work in my account but not for my visitors?
A signed-out visitor's request runs as the anon role. Row Level Security policies apply by role, so a policy that only covers authenticated returns zero rows to a visitor who is not signed in, and .single() then raises PGRST116.
Why does it return 406 and not 404?
PostgREST uses 406 Not Acceptable for a singular response that cannot be given, rather than the empty array and 200 status of a normal read. The 406 is the status for PGRST116 in PostgREST's error table.
Does .maybeSingle() hide the error when two rows match?
No. In the supabase-js source, the zero-row case becomes data: null with no error, while a result with several rows still returns PGRST116. A repeated value in a column that should be unique is a data problem to fix.
Can VibeFix fix it for me?
Yes, if you ask. The free check confirms the problem first. Our AI agent can find the cause, fix it in your code and test your live app again. It works on any app whose code is on GitHub, whichever tool built it (Lovable, Bolt, Base44, Replit, v0, Cursor). Lovable projects connect through Lovable's own GitHub sync.
Related: could not find the table in the schema cache · insert fails despite WITH CHECK (true) · permission denied for table (42501)
Related guides
- Supabase could not find the table in the schema cache
- Supabase RLS insert fails despite WITH CHECK (true)
- Supabase permission denied for table (42501)
- Supabase duplicate key value violates unique constraint
Sources
- <https://github.com/PostgREST/postgrest/blob/main/CHANGELOG.md> (13.0.0, 2025-05-08, item #3795)
- <https://docs.postgrest.org/en/stable/references/errors.html>
- <https://docs.postgrest.org/en/stable/references/api/resource_representation.html>
- <https://github.com/PostgREST/postgrest/pull/3795>
- <https://supabase.com/docs/reference/javascript/single>
- <https://supabase.com/docs/reference/javascript/maybesingle>
- <https://supabase.com/docs/guides/api/rest/postgrest-error-codes>
- <https://supabase.com/docs/guides/database/postgres/row-level-security>
- <https://www.postgresql.org/docs/current/view-pg-policies.html>
- <https://github.com/supabase/postgrest-js/blob/master/src/PostgrestBuilder.ts>
Last checked: 26 November 2026.
VibeFix is independent. Supabase is a trademark of its owner.
Want it fixed for you? For any app whose code is on GitHub, whichever tool built it, VibeFix's AI agent can find the cause of this error, fix it in your code and re-check your live app. Start with a free check: https://vibe-fixer.com
More guides · Shopify store accessibility · About · Your privacy choices