Skip to content
VibecodeZero

How to fix database errors in a vibe-coded app (Lovable, Bolt, Supabase)

Updated First published

On this page (4)
  1. Symptom
  2. Cause
  3. Prompt to paste
  4. How not to burn credits

Symptom

Something in your app fails to save, load or upload, and you see an error with a code like 42501, 23505 or PGRST116, or a message like "new row violates row-level security policy". Or a list shows nothing, with no error, even though the data is in the database.

Cause

This page is about error messages and codes that come from your app’s database. If your data vanished after a reload or only shows up on one device, with no error, see My data disappeared when I reloaded the page. If the whole backend of your published Lovable app stopped (login, data and AI all at once), that’s a different problem: see My published Lovable app stopped working.

The facts below come from Supabase’s docs on error codes, Row Level Security and the storage upload error, the PostgreSQL error code list, and Lovable’s docs on the database and logs, checked October 20, 2026. The Bolt facts come from Bolt’s help center pages on database security and database issues, checked October 26, 2026. Menu paths in Lovable were updated on October 28, 2026, from Lovable’s editor docs (section “The More menu”) and changelog, after the redesigned More menu. The note on new tables and grants comes from Supabase’s changelog post on the change, checked October 30, 2026.

Why database errors come with a code

Every Lovable project on the built-in backend (Lovable Cloud) includes a managed Postgres database. Apps connected to a Supabase project, whether you connected it in Lovable or in another tool such as Bolt, use Postgres too. When the database refuses something, it answers with a short code, and Supabase’s docs show errors coming back with four parts: a code, a message, sometimes details and sometimes a hint. For example, code 42703 with the message “column some_table.fake_col does not exist” and a hint.

You don’t need to understand the code. You need to copy it, because it tells the AI exactly what kind of problem it is.

Where to find the real error

  • On the screen. If your app shows an error, copy the whole text, code included.
  • In Lovable’s logs. Open More → Settings → Logs and choose PostgreSQL logs for database errors, or Authentication logs and Storage logs for sign-in and uploads. You can search, pick a time range up to the last 5 days, and filter to errors. Logs don’t update live, so click Refresh after you try again. Lovable’s docs say you can paste a log entry into the chat and ask Lovable to fix it.
  • In the SQL editor. If you ran a query in More → Database → Manage → SQL editor, a failed query shows its error message where the results would be.

Whenever you see an error, copy the full text, code included, right away so you can paste it into the chat.

The common errors, in plain English

Code What it means What to ask the AI
42501 Insufficient privileges. A security rule or a missing permission blocked the action. Which rule or permission blocked it, on which table, and the smallest change to allow it.
23505 Uniqueness violation. You tried to save a value that must be unique, and it already exists. Which column must be unique, and what the app should do when the value already exists.
23503 Foreign key violation. The change would break a link between two tables, like a row pointing to another row that isn’t there. Which two tables are linked, and why the link breaks.
23502 Not null violation. A required field was left empty. Which field is required, and where the app should fill it in.
22P02 Invalid text representation. A value wasn’t in a form the database could read for that field. Which value and which field caused it.
42P01 or PGRST205 Table not found. The app asked for a table that doesn’t exist. Which table the app is looking for, compared with the tables in the database.
42703 or PGRST204 Column not found. The app asked for a column that doesn’t exist. Which column the app is looking for, compared with the table’s real columns.
PGRST116 The app asked for exactly one row and got none, or more than one. Which request expects one row, and what to do when there are none or several.
PGRST301 The sign-in token the app sent couldn’t be read, or is invalid. Which request sent it, and how the app passes the signed-in user’s session.
42P17 Infinite recursion. Two tables’ security rules check each other and never finish. Which rules check each other, and how to break the loop with RLS still on.
53300 Too many connections. The database’s connection pool is full. Run a health check on the database first.
25006 Read-only. Supabase’s docs say the database switched to read-only mode because of disk quota. Run a health check on the database first.
57014 Query canceled. The database stopped the query before it finished. Which query was canceled and why.

Where the table only gives the name of an error, like 22P02 or 57014, that’s all the official lists say about it. The AI can tell you the cause in your app once it sees the full message.

Permission errors: 42501 and “new row violates row-level security policy”

Your app’s database has security rules, called RLS (Row Level Security) policies. Supabase’s docs describe a rule as a WHERE clause added to every query: it decides which rows each person can read, add, change or delete. Lovable’s docs say it sets these rules up automatically when it builds features that store user data, so one user’s private data isn’t shown to another.

When a rule or a permission says no, you usually get 42501. Supabase’s docs list two ways it happens:

  • A missing permission on the table. This fails before any rule runs, so Supabase suggests checking permissions before changing the rule.
  • A row the rule doesn’t allow. For example, trying to save a row that belongs to someone else.

A new table that says “permission denied for table”? Since October 30, 2026, Supabase no longer exposes new tables in the public schema to the Data API automatically, in every project. If your app uses its own Supabase project through supabase-js, a table created after that date returns 42501 until it gets a GRANT, even with correct RLS rules. See Supabase “permission denied for table” (42501) on a new table for the check and the fix.

Supabase’s docs also say the database answers 42501 with status 403 when the person is signed in, and 401 when they aren’t. That’s a quick clue about whether signing in is part of the problem.

Uploading a file? The message “new row violates row-level security policy”, with a 403 Forbidden, has a common cause, according to Supabase’s troubleshooting docs. An upload saves the file’s details and then reads them back. If there’s no read (SELECT) rule that lets the user see the file they just uploaded, the read fails and the whole upload fails, even when the upload (INSERT) rule is correct. The fix is a SELECT rule on the storage table that mirrors the INSERT rule.

To see the rules yourself in Lovable, open More → Database, select Manage, then Policies. Each rule shows its name, the action (SELECT is reading, INSERT is adding, UPDATE is changing, DELETE is removing), who it applies to (signed in or anonymous) and its condition. That view is read-only. To change a rule, ask Lovable in the chat, in plain words, like Lovable’s own example: “Only allow users to see their own invoices.”

In Bolt, click the database icon at the top center of your project, then Security. Bolt’s docs say this page finds problems like a missing RLS policy or a policy that’s too open, using the same checks as Supabase’s Security Advisor, and shows an Ask Bolt to fix button when it finds something and you can edit the project. Bolt turns on RLS for the tables it creates. If you add tables yourself, make sure RLS is on for those too.

42P17, infinite recursion, is also about rules. Supabase’s docs say it happens when two tables’ rules read each other, like a shared list whose rule checks the list’s members, while the members’ rule checks the list. The query then fails for everyone the rules apply to.

The list is empty, but there’s no error

This one is confusing because nothing looks wrong. Supabase’s docs explain that only some denials raise an error. When a rule’s condition filters a row out, the database raises nothing and the query matches zero rows. So you get an empty list, or an update that silently changes nothing.

Two common reasons, from Supabase’s docs:

  • The person isn’t signed in. For someone who isn’t signed in, auth.uid() is null, so a rule like “people see their own rows” returns nothing for them.
  • There’s no read rule. Changing a row (UPDATE) also needs a matching read (SELECT) rule. Without it, the update doesn’t work as expected.

Ask the AI to check the RLS policies for that table and whether the user is signed in when the list loads. If the empty list only happens on your published app, also see Lovable preview works, published app doesn’t.

Errors about the database itself

Some codes come from the platform, not from your app’s code. Supabase’s docs say that when you see these in volume, you should check the database dashboard before debugging your app’s code:

  • 53300, too many connections: the connection pool reached its limit.
  • 25006, read-only: the database entered read-only mode because of disk quota.
  • 57P03: the database can’t accept connections, usually during a restart or failover.

On Lovable Cloud, ask in the chat: “Run a health check on my Cloud database.” Lovable’s docs say it returns connections, memory, disk usage and recent pressure alerts. If the app feels slow, Lovable’s docs suggest: “My app feels slow. Find the slowest database queries and optimize the worst ones.” And if the Database view shows Your app is under high load, click Resolve.

On a Bolt database, Bolt’s docs say to check status.bolt.new first for an active incident. If Bolt reports that your database is unresponsive, timing out or having connection issues, restart it from the Advanced database settings. If it still doesn’t respond, contact Bolt support.

What not to do

  • Don’t “fix” a permission error by turning RLS off. Supabase’s docs say a table without RLS in an exposed schema can be read and changed by anyone with access to it, and recommend RLS on every such table. An error is annoying. Your customers’ data open to everyone is much worse. See Could my app be exposing personal data?
  • Don’t put the service_role key or a secret key in the browser. Supabase’s docs say it bypasses RLS entirely, so it must stay server-side and never be exposed to customers.
  • Don’t ask for big rebuilds. Lovable’s docs say Lovable records every database change as a migration and refuses changes that could break your published app, like dropping or renaming a table or column, changing a column’s type, or adding a required column without a default. It adds a new column instead. That protection is there for a reason.

If something did go wrong

Lovable takes a daily backup of the Cloud database and keeps up to roughly 14 days, in More → Database, under Manage. Restoring is permanent: anything created or changed after that backup is lost, and the database structure goes back too. Lovable’s docs suggest asking it to test the app and fix any mismatches after a restore. Use it as a last resort, not as a first fix for an error message.

Prompt to paste

Copy the text below, replace what’s in brackets and send it in the chat of the tool you’re using.

Paste into the AI
I got this database error: [paste the exact error text, including the code]
What I was doing when it happened: [for example "saving a new client" or "uploading a photo"]
Was I signed in to the app: [yes / no / not sure]

Don't change anything yet. Explain in plain English:
1. What this error means, and which table, column or security rule (RLS policy) it refers to.
2. The smallest change that would fix it.
Keep RLS turned on for every table, and don't use the service_role or secret key in the browser.
Wait for my confirmation before making any change.

How not to burn credits

  • Copy the exact error from the screen or from More → Settings → Logs instead of describing it. The code tells the AI where to look, so it doesn't have to guess.
  • Send one diagnostic prompt, like the one on this page, and read the answer before asking for a fix.
  • Don't ask the AI to "rebuild the database" or start it over. The error is usually about one rule, one column or one value, and a rebuild changes far more than that.
  • For codes about the database itself, like 53300 or 25006, start with the check from Lovable's docs, "Run a health check on my Cloud database.", instead of asking for code changes.

How Lovable counts credits, and what the free plan includes: Lovable credits explained.

Questions people ask

What does error 42501 mean in Supabase or Lovable?

It means insufficient privileges, so the database refused the action. Supabase's docs say a missing permission on the table raises 42501 before any security rule runs, and trying to save a row that a rule doesn't allow raises it too. Ask the AI which rule or permission blocked it and for the smallest change to allow what you need. Don't turn RLS off to make it go away.

Why do I get "permission denied for table" on a new Supabase table?

If your app uses its own Supabase project through supabase-js, this is probably Supabase's October 30, 2026 change. Since that date, new tables in the public schema aren't exposed to the Data API automatically, in every project, so a new table returns 42501, "permission denied for table", until it gets an explicit GRANT. Tables you already had keep working. The fix is a migration that adds the grants and, in the same file, turns on RLS and adds policies. Our page Supabase "permission denied for table" (42501) shows how to check and fix it.

Why do I get "new row violates row-level security policy" when uploading a file?

Supabase's troubleshooting docs say this usually happens because the upload saves the file's details and then reads them back, and there's no read (SELECT) rule that lets the user see what they just uploaded. It can happen even when the upload (INSERT) rule is correct. The fix is a SELECT rule on the storage table that matches the INSERT rule.

What does PGRST116 mean?

The app asked the database for exactly one row and got none, or more than one. Ask the AI which request expects a single row, and what the app should do when there's no row or there are several.

The data is in the database but my list shows nothing and there's no error. Why?

A security rule (RLS) can filter rows out without raising an error. Supabase's docs say that when a rule's condition filters a row out, the query simply matches zero rows. And for someone who isn't signed in, auth.uid() is null, so a rule like "people see their own rows" returns nothing for them. Ask the AI to check the RLS policies for that table and whether the user is signed in.

Can I just turn off RLS to make the error go away?

No. Supabase's docs say a table without RLS in an exposed schema can be read and changed by any role with access to it, and recommend turning RLS on for every such table. The same goes for the service_role key or a secret key, which skips the rules entirely. Supabase says to keep it server-side and never use it in the browser.

How do I find RLS problems in a Bolt database?

Open your Bolt project, click the database icon at the top center of the screen, then click Security. Bolt's docs say this page, available on all plans, finds problems like a missing RLS policy or a policy that's too open, using the same checks as Supabase's Security Advisor. If it finds an issue and you can edit the project, click Ask Bolt to fix. Bolt turns on RLS for the tables it creates, but if you add tables yourself, check them too. Open the Security page again after any database change.

My Bolt database isn't responding. What do I do?

Bolt's troubleshooting docs say to check status.bolt.new first for an active incident. If there isn't one and Bolt reports the database as unresponsive, timing out or having connection issues, restart the database from its Advanced database settings. If it still doesn't respond after the restart, contact Bolt support. The support options depend on your plan.

New guides by email. An email when we publish a new guide, error fix or chapter, in plain English. Subscribe