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.
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.
Open Supabase Dashboard and navigate to the SQL Editor. Run this query to list all tables in the public schema:
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.
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.
If you recently created migrations, they may not have been deployed yet. Use Supabase CLI to push migrations:
supabase db pushIf 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.
If your table is in a schema other than public, you must specify the schema:
SELECT * FROM your_schema.your_table;View all schemas:
SELECT schema_name
FROM information_schema.schemata;For Supabase Auth tables, use the auth schema:
SELECT * FROM auth.users;If your table name has uppercase letters, you must quote it every time:
// 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.
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:
CREATE POLICY "Allow public select" ON your_table
FOR SELECT USING (true);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.
email_address_not_authorized: Email sending to this address is not authorized
Email address not authorized for sending in Supabase Auth
reauthentication_needed: Reauthentication required for security-sensitive actions
Reauthentication required for security-sensitive actions
no_authorization: No authorization header was provided
How to fix "no authorization header was provided" in Supabase
otp_expired: OTP has expired
How to fix 'otp_expired: OTP has expired' in Supabase
bad_oauth_state: OAuth state parameter is missing or invalid
How to fix 'bad_oauth_state: OAuth state parameter missing' in Supabase