afterbuild/ops
ERR-589/Clerk · Authentication
ERR-589
ERR_TOO_MANY_REDIRECTS

appears when:A Clerk-backed app repeats sign-in, dashboard or session-refresh requests instead of reaching its intended state.

Clerk redirect loop in Next.js production

Trace the first request that loses the expected session state, then fix that branch while preserving access controls.

Last updated 30 October 2026 · 9 min read · By Hyder Shah
Direct answer
A Clerk redirect loop is a symptom, not a diagnosis. First separate a page that repeatedly sends the browser between /sign-in and /dashboard from an SDK error about repeatedly refreshing a session token. Then identify which request first loses the expected state. A public sign-in page, the right instance and a completed session solve different problems; changing all three at once hides which one mattered.

How do I fix a Clerk redirect loop?

Open the browser's Network panel with Preserve log enabled. Reproduce the problem in a non-production test environment with a test account. Record the request path, status, next location and whether Clerk reports an active, pending or missing session. Redact cookie values, tokens, user details and private query parameters before sharing the trace.

Use this evidence to choose a branch. The examples below are diagnostic illustrations, not measured customer cases.

Clerk redirect diagnosis by observed state
What the trace showsWhat to inspect nextWhat it does not establish
/sign-in immediately redirects to /sign-inA parent layout, page guard or early redirect is protecting the page needed to authenticateThat Clerk's session service is down
/sign-in → /dashboard → /sign-in after a successful sign-inThe server's session state at the dashboard, the destination settings and any pending session taskThat the matcher alone is responsible
Sign-in completes, then the app keeps returning to onboarding or organization selectionWhether the required task is complete and whether the task page can be reachedThat the user needs a new account
Preview fails while the configured production domain worksThe exact deployed instance, keys and domain configurationThat every preview domain should be trusted
A satellite returns from the primary domain without recognizing the sessionThe satellite link and synchronization configurationThat deleting all cookies is a durable fix
The SDK logs repeated session-token refreshes rather than a page redirect chainThe exact error, package versions, instance changes and server clockThat a sign-in route exclusion will fix it

This guide covers redirect and session-recognition failures in Clerk-backed Next.js apps. For paid implementation help, see our authentication specialist. A general production OAuth callback mismatch has a separate diagnostic owner. There is no need to replace Clerk merely because a redirect loops.

Not a developer? We fix this for you at a fixed price: $299 emergency triage, done in 48 hours or fully refunded. Not sure what else is broken? Send the repo for the $49 audit.

What if the quick fix doesn't work?

01 · Use the matching diagnosis below

The guide separates navigation, session tasks, environment and synchronization. Change the demonstrated cause, then verify the expected state transition.

Sign-in must be reachable; data must stay protected

A visitor cannot authenticate through a page that itself demands an authenticated session. Check the sign-in page and every parent layout or client wrapper that can redirect before Clerk renders. A route can be matched by clerkMiddleware() without being protected: Clerk's current Next.js quickstart says the helper supplies authentication context and leaves routes public by default. The important question is which code actually requires a user.

For a current Next.js App Router integration, Clerk's quickstart uses proxy.ts on Next.js 16 and later, and middleware.ts on earlier versions. Match the installed versions before borrowing an example. Renaming the file is not, by itself, a redirect-loop fix.

Clerk now marks createRouteMatcher() deprecated for auth protection and recommends checks in each server resource. Its migration guide says existing behavior has not changed; a deprecation warning does not prove that helper caused this incident. Keep clerkMiddleware() to supply context and enforce authentication where a page, Route Handler or Server Action accesses protected information. Do not remove the only access check simply to make the redirect disappear.

Next.js makes the same boundary clear: Proxy can help with an early redirect, but it is not a complete authorization or session-management solution. A dashboard that loads after all protection has been removed is not a repaired dashboard.

Sources: Clerk's Next.js quickstart, middleware reference, resource-based migration guide, and Next.js Proxy guidance.

Check where Clerk is supposed to send the user

The sign-in path and the destination after sign-in are different settings. Confirm that NEXT_PUBLIC_CLERK_SIGN_IN_URL points to the page actually hosting Clerk's sign-in component. A custom App Router sign-in page uses a catch-all route so nested authentication steps can render.

Next, distinguish a forced destination from a fallback. Clerk documents that a force redirect overrides the return destination, while a fallback is used when no return URL is present. Inspect both component props and environment configuration; a correct-looking value in one place does not settle a conflicting value elsewhere. Define the intended sign-up behavior too, because a user can switch flows from the sign-in screen.

For example, suppose the user requests /reports, is sent to sign-in, then lands on /dashboard instead. If the session is active and no request repeats, this is a destination choice, not an infinite loop. Removing the force setting may preserve the requested destination, but the correct choice depends on the product's intended navigation.

Sources: custom sign-in page and redirect URL behavior.

A pending session is not the same as a missing session

Clerk can require a task after authentication, such as choosing an organization. Its documentation says a pending session is treated as signed-out by default. An app that turns every signed-out-looking state into a fresh sign-in can send a user back through authentication instead of allowing them to finish the task.

Trace the task state before changing cookie or redirect settings. Keep the task route reachable and complete the required flow. Do not set treatPendingAsSignedOut to false across the app just to make protected screens appear. That changes the access model rather than explaining why the expected task never finishes.

An illustrative failure is: credentials accepted → session pending → dashboard requires an active session → sign-in → same pending session. The useful intervention is the missing task path or completion logic. The navigation trace alone cannot prove that credentials were rejected.

Source: Clerk session tasks and pending-session handling.

Production-only and satellite-only loops need their own checks

Compare the exact deployment against the intended Clerk instance. A development build, production instance and unconfigured preview hostname are not interchangeable. Clerk documents a specific redirect_url_not_associated_with_instance error when a redirect host is not configured for a production instance. Use that actual error to guide the investigation; do not turn on every domain or copy production credentials into arbitrary previews.

Check the instance's current domain and Frontend API configuration against Clerk's production documentation. Record the reported validation state before changing anything. A missing domain setup can matter, but browser-specific behavior alone does not prove a universal cookie or DNS cause.

A satellite app has another handoff. Clerk's current default satelliteAutoSync: false syncs after a user initiates sign-in rather than redirecting every first visit. The documented link builders add the sync trigger needed when the user returns. A hardcoded link can omit it. Review the primary-to-satellite return sequence before enabling automatic first-visit redirects; those redirects change the navigation behavior and are not a general cure.

Sources: Frontend API errors, production deployment, and satellite-domain synchronization.

What if the error says the session token keeps refreshing?

Keep the literal SDK error and installed version in the incident record. Historical Clerk issue #1418 documented inaccurate server time, changed instance keys and SDK-version issues as separate possibilities for its token-refresh error. That 2023 report is useful counterevidence to the claim that every Clerk loop is a route matcher problem. It is not evidence that an old workaround fixes a current SDK.

Compare the observed message against current vendor guidance for your installed release. After a deliberate instance change, a clean test profile can help distinguish stale browser state from a reproducible server failure. Clearing cookies without explaining the recurrence does not complete the investigation. Do not print keys or session objects into a public issue to demonstrate the configuration.

Source: historical Clerk SDK issue #1418.

Verify the state transition, not only the final URL

A useful regression check covers the expected states separately: a signed-out visitor can reach sign-in; a fully active session reaches the intended resource; a pending user can complete the required task; and an unauthorized direct data request remains denied. Repeat the relevant case on the affected deployment and browser, then confirm sign-out does not leave the app displaying protected information.

Keep the original failure trace, the changed cause and the passing trace together. If only one symptom was reproduced, keep the other branches marked untested. Avoid broad production auth experiments when a controlled staging reproduction can answer the question.

If the page loads but the underlying session behavior still fails, continue with sessions expiring immediately or users unable to log in after deployment. If you need implementation help, the auth specialist page owns that buying task; this page remains the technical diagnosis.

Tried the fix and still broken?

Send your app URL. A senior engineer records a 10-minute teardown.

Free, and fully async — no call to book. A senior engineer walks your app on video: what’s broken, what’s risky, what to fix first. In your inbox within 24 hours. Want the code read line by line instead? Send the repo for the $49 audit.

Why do AI-built apps hit a Clerk redirect loop?

A redirect loop can cross separate systems: application navigation, Clerk session status, instance configuration and server-side access checks. The first repeated URL tells you where to investigate; it does not prove every layer failed. Preserve the evidence from the affected version instead of treating the AI builder or auth provider as a universal cause.

How do I stop a Clerk redirect loop recurring?

Still stuck with a Clerk redirect loop?

Emergency triage · $299 · 48h turnaround
We restore service and write the root-cause report.
start the triage →

a Clerk redirect loop questions

Why does Clerk send me back to sign-in after login?+
Check the first request that loses the expected state. Possible branches include a protected sign-in page, conflicting post-sign-in destinations, a pending session task, an instance/domain mismatch or a satellite synchronization failure. The redirect chain does not establish one universal cause.
Should I remove Clerk middleware to stop the redirect loop?+
Do not remove the only access check. Clerk middleware supplies authentication context; current Clerk guidance recommends protecting each server-side resource. Keep sign-in reachable while ensuring protected pages, Route Handlers and Server Actions still deny unauthorized access.
Does Next.js 16 use middleware.ts or proxy.ts with Clerk?+
The current Clerk quickstart uses proxy.ts for Next.js 16 and later, and middleware.ts for Next.js 15 and earlier. Confirm the installed Next.js and Clerk versions. Renaming the file alone does not diagnose a redirect loop.
Can choosing an organization cause a sign-in loop?+
A required organization-selection task can leave a Clerk session pending. Pending sessions are treated as signed-out by default. If the app sends that state back to sign-in instead of the task page, authentication may repeat. Complete the intended task; do not bypass the gate just to expose protected content.
Why does Clerk work on production but fail in preview?+
Compare the deployed instance and domain configuration. Clerk documents redirect_url_not_associated_with_instance for an unconfigured redirect host on a production instance. Use an appropriately configured development or staging setup for previews rather than trusting arbitrary hostnames.
Is a session-token refresh error the same as a sign-in redirect loop?+
Not necessarily. Keep the literal SDK error and installed versions. Historical vendor reports include changed instance keys and inaccurate server time as distinct possibilities for repeated token refreshes. A historical workaround is not proof of a fix for the current release.
Next step

Ship the fix. Keep the fix.

Emergency Triage restores service in 48 hours. Break the Fix Loop rebuilds CI so this error cannot ship again.

About the author

Hyder Shah leads Afterbuild Labs, shipping production rescues for apps built in Lovable, Bolt.new, Cursor, Replit, v0, and Base44. our rescue methodology.

Sources