Next.js: Error: NEXT_REDIRECT (redirect() inside try/catch)
redirect() works by throwing a special error; catching it in try/catch (or a .catch) swallows the redirect and logs NEXT_REDIRECT.
Seen on:
Next.js
Meaning
In Server Actions and Server Components, redirect() and notFound() throw control-flow errors. Call them outside try/catch, or rethrow them using unstable_rethrow / isRedirectError.
Common causes
- redirect() called inside try { }
- Generic catch logging all errors
- Wrapping server action logic in try/catch
⚡ Quick fix
- Move redirect() after the try/catch block
- Rethrow framework errors with unstable_rethrow(error)
- Return a value and redirect afterwards
Detailed fix by platform
TypeScript
- tsx
export async function createPost(form: FormData) { "use server"; let id: string; try { id = await db.post.create(form); } catch (e) { return { error: "Failed" }; } redirect(`/posts/${id}`); }
How to diagnose
- Location — Is redirect() inside try?
- Catch — Does it swallow errors?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- cookies() should be awaited Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value
- Dynamic server usage Error: Dynamic server usage: Route /x couldn't be rendered statically because it used `cookies`
- server-only Next.js: You're importing a component that needs "server-only". That only works in a Server Component
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026