Deploy Koop app to Heroku

Heroku is a cloud platform as a service (PaaS) supporting multiple languages including Node.js. Its fully managed service and pay-as-you-go pricing model are particularly useful for testing and running Koop apps.

In this section, we show how to deploy a Koop app to Heroku using the Heroku CLI. The following guideline is based on a Koop app generated by the Koop CLI (like this) but should be applicable to all Koop apps.


The deployment needs Git and Heroku CLI. Please read the documentation for details.


Before deploying the app, you need to specify the Node.js version and the server port for the Heroku dynos.

The Node.js version number can be added to the package.json in your app root directory.

  "engines": {
    "node": "12.x"

Heroku dyno uses a dynamic port per machine and specifies it in the environment variable. You can update the src/index.js to use the provided port number.

// This is the original code at line 22
// koop.server.listen(config.port, () =>`Koop server listening at ${config.port}`))

// You can replace the config.port by process.NODE_ENV.$PORT
const port = process.NODE_ENV.$PORT
koop.server.listen(port, () =>`Koop server listening at ${port}`))

Now the app should be ready for deployment. You can verify the app locally using the heroku local command, which is installed as part of the Heroku CLI.

heroku local web

Your app should now be running on http://localhost:5000/.


Now you can finally deploy your app to Heroku.

First, prepare the Heroku credential if you have not signed in at the CLI.

Second, run the heroku create command to set up an empty app instance at Heroku.

Third, push your app code the Heroku with git push heroku master.

Fourth, no, there is no step four.

That’s it. Now you can check your Heroku console and test out your app!


Heroku provides a series of articles discussing the Node.js app deployment and you may find them useful in your process:

Improve this page