Heroku Build Failed Error
Quick answer
'Build failed' or 'Push rejected, failed to compile' means the buildpack could not build your app. The lines above the failure say why; the usual causes are lockfile, version and missing dependency problems.
Most likely fix: Read the build output
How to fix it
Try these in order — the most common fix is first.
1. Read the build output
- Scroll to the first error in the remote: lines
- Search that exact message; most are dependency or version errors
Did this fix it?2. Confirm the buildpack
- Run heroku buildpacks
- Set it: heroku buildpacks:set heroku/nodejs (or heroku/python, heroku/ruby)
Did this fix it?3. Pin the runtime version
- Node: add "engines": {"node": "22.x"} to package.json
- Python: add runtime.txt or .python-version
- Match your local version
Did this fix it?4. Sync and commit the lockfile
- npm install / yarn install / pnpm install
- Commit package-lock.json, yarn.lock or pnpm-lock.yaml
Did this fix it?5. Do not commit node_modules
- git rm -r --cached node_modules
- Add node_modules to .gitignore
- Check .gitignore rules like lib/ that may exclude real source folders; use /lib
Did this fix it?6. Run the build in a one-off dyno
- heroku run bash -a <staging-app>
- Run your build script there with --verbose to see the real error
Did this fix it?7. Clear the build cache if it is stale
- Install the heroku-builds plugin: heroku plugins:install heroku-builds
- Run heroku builds:cache:purge -a <app> then redeploy
Did this fix it?
Symptoms
git push heroku main ends with '! Push rejected, failed to compile ... app' or 'Build failed'.
Why it happens
- Wrong or missing buildpack
- Node, Python or Ruby version mismatch
- Lockfile not committed or out of sync
- node_modules or other generated folders committed
- devDependencies pruned but needed at runtime
- Build script that only works locally
This guide also covers
- heroku build failed
- heroku push rejected failed to compile
- heroku buildpack error
- heroku deploy failed
Still not working?
If Heroku keeps failing, you're not alone. See every Heroku problem users report or the alternatives people switch to.
Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.
Talk to usThe same problem in other apps
All export, render & quality loss guides →
- DigitalOcean App Platform Build Failed (DigitalOcean)
- Vercel Deployment Failed: Build Error (Vercel)