DEV Community

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

Posted on • Edited on

1 1

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

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay