ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabaseโ€ข4y agoโ€ข
14 replies
jxyz

supabase.auth.api.createUser duplicate key value violates unique constraint users_pkey

I have a server-side code using the service key,

const email = 'alice@gmail.com';
const password = 'test1234';
const create_user_response = await supabase.auth.api.createUser({ email, password, email_confirm: true });
const email = 'alice@gmail.com';
const password = 'test1234';
const create_user_response = await supabase.auth.api.createUser({ email, password, email_confirm: true });


I am getting the following error, I am clueless why this happens. Any ideas?

{
  user: null,
  data: null,
  error: {
    message: 'duplicate key value violates unique constraint "users_pkey"',
    status: 500
  }
}
{
  user: null,
  data: null,
  error: {
    message: 'duplicate key value violates unique constraint "users_pkey"',
    status: 500
  }
}
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

duplicate key value violates unique constraint "profiles_pkey"
SupabaseSSupabase / help-and-questions
3y ago
duplicate key value violates unique constraint Key (id)=(5)
SupabaseSSupabase / help-and-questions
3y ago
duplicate key value violates unique constrain
SupabaseSSupabase / help-and-questions
13mo ago
violates foreign key constraint
SupabaseSSupabase / help-and-questions
4y ago