Supabase confirmation email opens localhost:3000

Updated

Error messagelocalhost refused to connect (after clicking the confirmation or password reset link)

The Site URL in Supabase Auth settings is still the default http://localhost:3000, and emails use it whenever your code doesn’t pass a redirect. Set Site URL to your production address, add preview domains to the Redirect URLs allow list, and pass emailRedirectTo when signing users up.

Fix the setting

  1. Open Authentication → URL Configuration in the Supabase dashboard.
  2. Set Site URL to your production address, for example https://app.yoursite.com.
  3. Add every other address users may come from to Redirect URLs: your custom domain, the platform domain and preview URLs.

Wildcards: * matches anything except . and /, ** matches everything. Use exact URLs for production and keep ** for previews, for example https://*-yourteam.vercel.app/**.

Pass the redirect in code

await supabase.auth.signUp({
  email,
  password,
  options: { emailRedirectTo: `${window.location.origin}/welcome` }
})

await supabase.auth.resetPasswordForEmail(email, {
  redirectTo: `${window.location.origin}/reset-password`
})

The URL must match an entry in Redirect URLs. If it doesn’t, Supabase silently falls back to the Site URL.

If you edited the email templates, they use {{ .SiteURL }} by default. Switch to {{ .RedirectTo }} where you want the per-request address.

Check that it worked

Sign up with a new address from the production site and from a preview deployment. Both links must open the site they came from. Links already sent keep the old address, so test with a fresh email.

Sources