DEV Community

Cover image for How to deploy a Node, Postgres app to Heroku.
jean luc tuyishime
jean luc tuyishime

Posted on • Updated on

How to deploy a Node, Postgres app to Heroku.

Link to configure Node and Postgres Link

I assume you are developing a Node, Postgres app and maybe facing challenging on how to deploy your app to Heroku.

1. If you are using the configurations in your local environment using .env you need to add them in your Heroku app settings.

Alt Text

2. Install Postgres in Heroku

  • Click on your app
  • Click on Configure Add-ons
  • Search Postgres and Install it
  • Click on Heroku-Postgres Add-on
  • Select Settings
  • Click on View Credentials

3. Let’s Connect to online Postgres Database via CLI

psql -h hostname -d databasename -U username
Enter fullscreen mode Exit fullscreen mode

Check your DataBase informations by clicking

Alt Text

And go in the settings tab and replace them respectively using the command below

psql -h xxx-xx-xxx-xxx-xxx.compute-1.amazonaws.com -d xx9n7dxxhxx -U yhxxzyxxxezhxx
Enter fullscreen mode Exit fullscreen mode

3 After connecting to Heroku via CLI, You can now create tables

  • An example of how to create a table using the CLI
CREATE TABLE users(id serial PRIMARY KEY, "firstName" VARCHAR (255) NOT NULL, "lastName" VARCHAR (255) NOT NULL, username VARCHAR (255) UNIQUE NOT NULL, email VARCHAR (255) UNIQUE NOT NULL, phone VARCHAR (255) UNIQUE NOT NULL, password VARCHAR (255), role VARCHAR (255) NOT NULL, "isActive" VARCHAR (255), "createdAt" TIMESTAMP, "updatedAt" TIMESTAMP );
Enter fullscreen mode Exit fullscreen mode
  • You may encounter SSL issues after creating your tables, in your production setup object in config file add
 dialectOptions: {
            ssl: {
                require: true,
                rejectUnauthorized: false,
            },
        },
Enter fullscreen mode Exit fullscreen mode

Top comments (0)