Fix guides · Netlify ·
Fix Netlify build failures
Netlify build failed / deployment error
A Netlify build failed; the logs show the specific error that prevented deployment.
Common causes – and how to tell which one you have
1. Missing environment variable
How to tell: The build log shows an error about an undefined environment variable at build time.
Fix: Add the variable in Netlify under Site configuration → Environment variables.
2. Incorrect build command
How to tell: The log shows the build command was not found or exited with a non‑zero status.
Fix: Check netlify.toml or the UI build setting and adjust to the project's actual command (e.g., "npm run build").
How to fix it
- Open the Netlify dashboard → Site → Deploys → click the failed deployment.
- Read the error message and log excerpt.
- Set the required environment variables in Netlify under Site configuration → Environment variables.
- Verify the build command in netlify.toml matches the project's setup.
- Leave the publish directory to Netlify's framework auto-detection; only change it if you use a custom output folder.
- Redeploy after fixing the configuration.
Using Lovable, Bolt or v0?
Always verify environment variables in Netlify under Site configuration → Environment variables after a fork or new repo clone.
Using Cursor, Claude Code or Windsurf?
Ask the agent to capture the exact build log, then check environment variables and build command before re‑deploying.
The “fix” to avoid
Do not simply disable the build hook or change the publish directory without understanding the root cause; this can hide the real issue and cause later failures.
Copy-paste fix prompt for your AI coding tool
Paste this into Cursor, Claude Code, Lovable or Bolt:
My Netlify build failed. First check the deployment logs for the exact error. Then ensure all required environment variables are set in the Netlify site settings and the build command is correct. Redeploy and verify the site is live.