Error: NEXT_REDIRECT
Error: NEXT_REDIRECT
at getRedirectError
at redirectIn one sentence: Next.js redirect() works by throwing a special error. A try/catch around it catches that error, so the redirect never happens and NEXT_REDIRECT shows up in your logs or UI.
What it means
`redirect()` and `notFound()` from `next/navigation` don't return. They throw an error that Next.js catches higher up to perform the redirect or show the 404 page. If your own `try/catch` catches it first, you've swallowed the redirect.
That's why you see `NEXT_REDIRECT` printed by your `console.error`, shown in an error toast, or returned from a server action instead of the user being sent to the new page.
Common causes
- `redirect()` is called inside a `try` block in a server action, route handler or Server Component.
- A catch-all error handler logs or returns every error, including the redirect.
- `redirect()` is called in a Client Component event handler, where `router.push()` should be used instead.
How to fix it
- Move `redirect()` after the `try/catch`: do the risky work inside `try`, store the result, and redirect once the block is done.
- If it must stay inside, rethrow Next.js internal errors first: `import { unstable_rethrow } from "next/navigation"` and call `unstable_rethrow(err)` at the top of the `catch`.
- In Client Components, use `const router = useRouter(); router.push("/dashboard")` from `next/navigation` for navigation after a click.
Before
"use server";
export async function save(form: FormData) {
try {
await db.insert(form);
redirect("/dashboard");
} catch (err) {
return { error: String(err) }; // swallows NEXT_REDIRECT
}
}After
"use server";
export async function save(form: FormData) {
try {
await db.insert(form);
} catch (err) {
return { error: "Could not save" };
}
redirect("/dashboard");
}Tried this and it's still broken? Paste your exact error for a free explanation of your specific case.
Prompt to paste into your AI tool
My Next.js app shows 'Error: NEXT_REDIRECT' instead of redirecting. Find every redirect() and notFound() call inside a try/catch, move them after the try/catch (or call unstable_rethrow(err) at the top of the catch), and replace redirect() in client event handlers with router.push(). Don't change unrelated code.Still stuck?
Paste your exact error and code. Get a plain-English explanation free, or the full fix for $5.
Hitting errors every day? Builder is $15/mo for 100 fixes per month. Compare plans
Related errors
- TypeScript: Type 'string | undefined' is not assignable to type 'string'
- git push rejected: failed to push some refs
- TypeError: Cannot read properties of undefined
- CORS error: blocked by CORS policy
Weekly: the errors breaking vibe-coded apps and how to fix them. Free.
No spam. Unsubscribe anytime.