Heroku Build Failed Error

Share
Workaround available All Updated November 13, 2026Based on 4 user reportsHow we research

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. 1. Read the build output

    1. Scroll to the first error in the remote: lines
    2. Search that exact message; most are dependency or version errors
    Did this fix it?
  2. 2. Confirm the buildpack

    1. Run heroku buildpacks
    2. Set it: heroku buildpacks:set heroku/nodejs (or heroku/python, heroku/ruby)
    Did this fix it?
  3. 3. Pin the runtime version

    1. Node: add "engines": {"node": "22.x"} to package.json
    2. Python: add runtime.txt or .python-version
    3. Match your local version
    Did this fix it?
  4. 4. Sync and commit the lockfile

    1. npm install / yarn install / pnpm install
    2. Commit package-lock.json, yarn.lock or pnpm-lock.yaml
    Did this fix it?
  5. 5. Do not commit node_modules

    1. git rm -r --cached node_modules
    2. Add node_modules to .gitignore
    3. Check .gitignore rules like lib/ that may exclude real source folders; use /lib
    Did this fix it?
  6. 6. Run the build in a one-off dyno

    1. heroku run bash -a <staging-app>
    2. Run your build script there with --verbose to see the real error
    Did this fix it?
  7. 7. Clear the build cache if it is stale

    1. Install the heroku-builds plugin: heroku plugins:install heroku-builds
    2. 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 us
Fixed it? Share this guide

The same problem in other apps

All export, render & quality loss guides →

Other Heroku errors

All 11 Heroku errors and fixes →