How to deploy a Nestjs/Postgres server to Heroku

I had some trouble deploying my NestJS/Postgres server to Heroku. To save anyone else (and possibly my future self) the headache, here are the steps. Repo here for reference/cloning.


  1. Heroku cli installed
  2. Repo running locally. (You can clone my example repo here)
  3. Local repo linked to local postgres db (not essential for the deploy but def recommended)


1. Create your app in heroku

2. Deploy your app

3. Configure the Procfile with the start command

4. Create a postgres db in heroku

5. Find db credentials

Heroku postgres link to DB GUI
DB credentials in GUI

6. Copy the credentials into heroku config variables

Now, when you run heroku logs --tail you’ll see the app connects to the db and starts successfully:

App starts successfully after the DB credentials were added

Overall, heroku makes deploying pretty intuitive. The two steps that tripped me up initially were setting the start command in the Procfile and adding the db credentials to the config vars.

Hopefully this will help others get their app up and running quickly!

(Originally published: Building in public)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store