Heroku Application Error when running CI build & Release Pipelines


If you are trying to deploy an app to Heroku and your deployment fails – use the following steps to diagnose and solve the issue.

Work from the correct directory

Ensure that you are in the correct directory when you are deploying your app. For instance, if you have the following structure:

— Client-app
— Server-app

If you want to deploy Server-app, the cd into this directory and issue all the commands from here.

Delete .git folder

Delete the .git and start again. The deployment step will sometimes fail because there are conflicts in your versioning. The easiest thing to do is to backup your .git folder and then delete it with the following command:

rm -rf .git

Check the Heroku logs

Check you Heroku application logs by issuing the following command:

heroku logs

This should reveal a log similar to the following:

2021-02-26T13:10:08.527421+00:00 app[web.1]: [nodemon] 2.0.3
 2021-02-26T13:10:08.528336+00:00 app[web.1]: [nodemon] to restart at any time, enter rs
 2021-02-26T13:10:08.528885+00:00 app[web.1]: [nodemon] watching path(s): .
 2021-02-26T13:10:08.528988+00:00 app[web.1]: [nodemon] watching extensions: js,mjs,json
 2021-02-26T13:10:08.529490+00:00 app[web.1]: [nodemon] starting node server.js
 2021-02-26T13:10:09.098481+00:00 app[web.1]: internal/modules/cjs/loader.js:883
 2021-02-26T13:10:09.098516+00:00 app[web.1]: throw err;
 2021-02-26T13:10:09.098516+00:00 app[web.1]: ^
 2021-02-26T13:10:09.098517+00:00 app[web.1]: 
 2021-02-26T13:10:09.098517+00:00 app[web.1]: Error: Cannot find module '../server/routes/student.route'
 2021-02-26T13:10:09.098518+00:00 app[web.1]: Require stack:
 2021-02-26T13:10:09.098518+00:00 app[web.1]: - /app/server.js
 2021-02-26T13:10:09.098519+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
 2021-02-26T13:10:09.098519+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:725:27)
 2021-02-26T13:10:09.098520+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:952:19)
 2021-02-26T13:10:09.098520+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:88:18)
 2021-02-26T13:10:09.098520+00:00 app[web.1]: at Object. (/app/server.js:20:20)
 2021-02-26T13:10:09.098521+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
 2021-02-26T13:10:09.098521+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
 2021-02-26T13:10:09.098521+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:928:32)
 2021-02-26T13:10:09.098525+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
 2021-02-26T13:10:09.098525+00:00 app[web.1]: at Function.executeUserEntryPoint as runMain
 2021-02-26T13:10:09.098526+00:00 app[web.1]: at internal/main/run_main_module.js:17:47 {
 2021-02-26T13:10:09.098526+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
 2021-02-26T13:10:09.098526+00:00 app[web.1]: requireStack: [ '/app/server.js' ]
 2021-02-26T13:10:09.098527+00:00 app[web.1]: }
 2021-02-26T13:10:09.104386+00:00 app[web.1]: [nodemon] app crashed - waiting for file changes before starting…
 2021-02-26T13:11:05.829439+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch


Ensure that your package.json has the correct Start scripts.

  "name": "Server-app",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "start": "nodemon"

Heroku will fail with the deployment if the correct start script has not been selected.

Leave a comment