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.
Tool picker
Open this when the payment problem is really making you question the app stack and workflow choice behind it.
Open this next →
Lovable reviews
Open this when repeated billing drift makes you question whether the current generated full-stack path is still worth the cleanup cost.
Open this next →
Cursor review
Open this when the next move is owning more of the billing and entitlement logic directly in code.
Open this next →
Deploy hub
Open this when the payment bug is really part of a bigger production handoff and environment problem.
Open this next →
Firecrawl review
Open this when the app also needs live data or richer infra decisions and the stack question is getting broader than Stripe itself.
Open this next →
Quick Fix Summary
| Most likely cause | Customer Portal not activated in Stripe, or the return_url is missing/wrong. |
| Fastest fix | Activate the portal |
| Use this page if | Portal 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
Activate the portal
Stripe Dashboard → Settings → Billing → Customer Portal → click Activate. Set your return URL to https://your-domain.com/dashboard.
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
Stripe Payment Succeeds but Subscription Status Never Updates
Stripe Payment Succeeds but the User Never Leaves Checkout
Lovable Stripe Checkout Fails or Cards Are Declined
How to Test Stripe Webhooks Locally
Stripe Says Webhook Signature Verification Failed
Accidentally Charged Real Money in Stripe