Stripe·Fixpaymentsintermediate

Stripe Customer Portal Link Returns an Error or 404

Quick Answer

How do I fix Stripe Customer Portal Link Returns an Error or 404?

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

Fix signals

What this answers
Why stripe customer portal link returns an error or 404 happens and what to change first.
Fastest move
Activate the portal
Use this page if
Portal link returns error

If this keeps happening

Open the next decision, not just the patch

Use these when the current fix is helpful, but the real answer is a better tool choice, a cleaner workflow layer, or a more trustworthy launch path.

Quick Fix Summary

Most likely causeCustomer Portal not activated in Stripe, or the return_url is missing/wrong.
Fastest fixActivate the portal
Use this page ifPortal link returns error

Exact errors people search for

If one of these matches what you are seeing, you are likely on the right fix page.

Stripe Customer Portal link returns an error or 404
Customers cannot open the billing portal to manage subscriptions
Portal opens with the wrong return URL and breaks

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