Stripe·Fixpaymentsintermediate

Stripe Customer Portal Not Working

Quick Answer

Customer Portal not activated in Stripe, or the return_url is missing/wrong. Start with "Activate the portal" before making broader code changes.

You're in the right place if...

  • !Portal link returns error
  • !Customers can't manage subscriptions
  • !404 on portal redirect

Why this happens

Customer Portal not activated in Stripe, or the return_url is missing/wrong.

Fix

1

Activate the portal

Stripe Dashboard → Settings → Billing → Customer Portal → click Activate. Set your return URL to https://your-domain.com/dashboard.

2

Create portal sessions correctly

Use the Stripe customer ID (not your internal user ID):

const session = await stripe.billingPortal.sessions.create({
  customer: customerId, // Stripe customer ID, not your user ID
  return_url: `${process.env.NEXT_PUBLIC_URL}/dashboard`,
})

redirect(session.url)

Prevent this next time

Store the Stripe customer ID in your database when a user first subscribes. You'll need it for portal sessions.

Frequently Asked Questions

Stripe customer ID (cus_xxx) is Stripe's identifier. Your user ID is from your auth system. Map them in your database.

Yes, if you enable cancellation in Portal Settings. You can also restrict it to only allow plan changes.

Related fixes

Weekly Newsletter

Get next week's fix before you need it.

Join developers getting weekly vibe coding tips, error fixes, and tool updates.

Subscribe on Substack →