Next.js "Failed to find Server Action" after a deploy: version skew and multiple instances
Forms and buttons that call a Server Action fail right after you deploy, with "Failed to find Server Action. This request might be from an older or newer deployment." Why open tabs and multi-instance hosting break Server Actions, and the Vercel, Replit, Docker, and Railway fixes.
Free · no card
Paste your error. Get a free diagnosis by email.
Tell us what broke and we’ll email you a short diagnosis: the likely cause and what to try first. Usually within a day.
What you are seeing
- Server logs show
Error: Failed to find Server Action "7f3a...". This request might be from an older or newer deployment. - A form or button does nothing, or shows a generic error, for users who had the page open before your last deploy. A hard refresh fixes it for them.
- On a self-hosted app with more than one instance (containers behind a load balancer, autoscaling), actions fail at random even without a new deploy.
- Sometimes the browser also requests old JavaScript chunks that now 404 (
ChunkLoadError).
Why it happens
- Each build gives every Server Action a new ID. A page loaded from the previous deployment still sends the old ID, and the new server does not recognize it. Next.js calls this version skew.
- On Vercel, Skew Protection routes those requests back to the deployment the page came from. It is a Pro and Enterprise feature, on by default only for projects created after November 19, 2024 with a supported framework, and it only covers deployments within its maximum age (12 hours by default on Pro).
- On your own servers, each instance that was built separately has its own Server Action encryption key. Next.js says all instances must share one key (
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY), or an action encrypted by one instance cannot be decrypted by another and you get the same error. - During rolling deploys, old and new instances serve traffic at the same time. Without a
deploymentId, the client cannot tell it is talking to a different version and does not reload.
How to fix it
1. Vercel: turn on Skew Protection
In the Vercel dashboard, open the project, Settings, Advanced, Skew Protection, and enable it (Pro or Enterprise). Make sure the project setting that gives access to System Environment Variables is on, raise Maximum Age if users keep tabs open for long, then redeploy production. On Hobby, use the reload fallback in the last step.
2. Self-hosted: give every instance the same encryption key
# generate once and store it as a secret in your host (Railway, Docker, Replit Deployments, Fly)
openssl rand -base64 32
# it must be present at build time; Next.js embeds it in the build output
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY=<that-value> next build
3. Set a deployment ID that changes every release
// next.config.js
module.exports = {
deploymentId: process.env.GIT_SHA, // or a release number from your CI
}
// or as an env var at build time (takes precedence over next.config.js)
// NEXT_DEPLOYMENT_ID=$GIT_SHA next build
4. Build once, run that build everywhere
Do not run next build separately on each container or instance. Build one image or artifact in CI and deploy the same one to every instance, so action IDs and assets match. If you must rebuild per environment, the Next.js self-hosting guide shows generateBuildId for a consistent build ID.
5. Recover gracefully in the browser
// wrap action calls so a stale tab reloads instead of failing silently
try {
await saveProfile(formData)
} catch (err) {
if (String(err?.message).includes('Server Action')) {
window.location.reload()
return
}
throw err
}
How to know it is fixed
Open the app in one tab, deploy a new version, then submit a form in the old tab without refreshing. With Skew Protection or a deployment ID, the action succeeds or the page reloads to the new version instead of failing. On self-hosted multi-instance setups, server logs show no new Failed to find Server Action errors across a day of traffic. Sources: Next.js: Self-hosting (encryption key, deployment ID, version skew), Next.js: deploymentId, Next.js: Data security (Server Actions), Vercel: Skew Protection. Related: Vercel deploy fails but it builds locally, Blank white screen after deploy.