How to fix 42P01: Undefined table in Supabase

SupabaseBEGINNERHIGHUpdated Dec 29, 2025· 167 views

PostgreSQL error 42P01 occurs when you query or reference a table that doesn't exist in your database. Fix it by verifying the table name spelling, checking the schema, running migrations, or quoting identifiers for case-sensitive names.

Quick fix

Fixes 42P01: Undefined table

SELECT table_name 
FROM information_schema.tables 
WHERE table_schema = 'public' 
ORDER BY table_name;
  1. Verify the table exists in your database
  2. Check spelling and exact table name
  3. Push pending migrations
  4. Check schema and use fully qualified table names
supabase — error
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
ORDER BY table_name;
42P01: Undefined table

What this error means

PostgreSQL error code 42P01 is an "undefined_table" error that occurs when your application tries to query or reference a table that doesn't exist in the database. This is a syntax error that prevents the query from executing. The error typically appears with additional context showing which table name PostgreSQL couldn't find. In Supabase, this usually happens when migrations haven't been run, table names are misspelled, or the table exists in a different schema than expected.

Typical symptoms

  • Query execution fails with "undefined table" error message
  • Application crashes when trying to access specific tables
  • Newly created migrations don't take effect immediately
  • Table operations work in Supabase Dashboard but fail in application code
  • Case-sensitive table names fail when referenced without quotes

Common causes

  1. Table doesn't exist yet or migrations haven't been deployed
  2. Table name is misspelled in the query (typo or casing issue)
  3. Table exists in a different schema than the one being queried
  4. PostgreSQL lowercases unquoted identifiers, causing case-sensitive name mismatches
  5. Connection is to the wrong database or project

How to fix "42P01: Undefined table"

1Verify the table exists in your database

Open Supabase Dashboard and navigate to the SQL Editor. Run this query to list all tables in the public schema:

sql
SELECT table_name 
FROM information_schema.tables 
WHERE table_schema = 'public' 
ORDER BY table_name;

Check if your table name appears in the results. If it doesn't, the table doesn't exist yet.

2Check spelling and exact table name

Carefully compare the table name in your error message with the actual table name in your database. PostgreSQL is case-sensitive for quoted identifiers:

- If your table is named users (lowercase), reference it as users
- If your table is named "Users" (quoted), you must always use quotes: SELECT * FROM "Users"
- Without quotes, PostgreSQL converts to lowercase: Users becomes users

Check your schema or migrations file for the exact table definition.

3Push pending migrations

If you recently created migrations, they may not have been deployed yet. Use Supabase CLI to push migrations:

bash
supabase db push

If using the dashboard only, migrations are applied immediately. If using Supabase CLI locally, you must explicitly push them to your project with the command above. Verify the migration succeeded by checking the tables again.

4Check schema and use fully qualified table names

If your table is in a schema other than public, you must specify the schema:

sql
SELECT * FROM your_schema.your_table;

View all schemas:

sql
SELECT schema_name 
FROM information_schema.schemata;

For Supabase Auth tables, use the auth schema:

sql
SELECT * FROM auth.users;
5Use quotes for case-sensitive table names

If your table name has uppercase letters, you must quote it every time:

javascript
// Incorrect - will fail if table is "UserProfiles"
const { data } = await supabase
  .from('UserProfiles')
  .select()

// Correct - use double quotes to preserve case
const { data } = await supabase
  .rpc('your_function', {})

// Or use all lowercase and create table as lowercase
const { data } = await supabase
  .from('user_profiles')
  .select()

Best practice: Always create tables with lowercase names using underscores (snake_case) to avoid quoting issues.

6Verify the table is visible with Row Level Security

Sometimes a table exists but Row Level Security (RLS) policies prevent you from seeing it. Check RLS settings:

1. Go to Supabase Dashboard > Authentication > Policies
2. Select your table from the dropdown
3. Verify policies allow SELECT access for your user role

If no policies exist, RLS may be disabled (which is fine). If policies exist but don't grant access, add a policy:

sql
CREATE POLICY "Allow public select" ON your_table
FOR SELECT USING (true);

Advanced notes

In development, test table creation thoroughly before deploying. If using Supabase CLI with migrations, the local database and remote database must stay in sync—run supabase db push after creating migrations locally. For applications using ORMs like Prisma, ensure migrations are generated and migrations are run: prisma migrate deploy. When working with multiple environments (dev, staging, production), verify you're connected to the correct database URL. Case sensitivity issues are common when migrating from other databases that don't enforce case rules; always use lowercase snake_case for PostgreSQL table names. If you see this error intermittently, it may indicate a connection or caching issue—try restarting your application.

Frequently asked questions

What does "42P01: Undefined table" mean?
PostgreSQL error code 42P01 is an "undefined_table" error that occurs when your application tries to query or reference a table that doesn't exist in the database. This is a syntax error that prevents the query from executing. The error typically appears with additional context showing which table name PostgreSQL couldn't find.
How do I fix "42P01: Undefined table"?
PostgreSQL error 42P01 occurs when you query or reference a table that doesn't exist in your database. Fix it by verifying the table name spelling, checking the schema, running migrations, or quoting identifiers for case-sensitive names.
What causes "42P01: Undefined table"?
Table doesn't exist yet or migrations haven't been deployed Table name is misspelled in the query (typo or casing issue) Table exists in a different schema than the one being queried
Is the "42P01: Undefined table" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading