- Client must have a Heroku account, with:
- An active subscription to the Eco Dynos Plan.
- A credit card on file so that they can pay for the Heroku Postgres Add-On.
- Client must create a new Heroku app. (This is essentially like creating a new/empty GitHub repository.)
- An install of the Heroku CLI. (CLI: Command Line Interface)
npm install -g heroku
- An install of PostgreSQL's CLI Tools.
- The ability to successfully authenticate with Heroku by typing
heroku loginin your Terminal.- This will prompt you to press a key and you'll be directed to log in through the Heroku web app.
- The project you'd like to deploy must be a
gitrepository. (Derp.)
Before you deploy, make sure your server PORT is configured correctly as:
const PORT = process.env.PORT || 5001;And make sure your **modules/pool.js** has some conditional code using process.env.DATABASE_URL like:
if (process.env.DATABASE_URL) {
config = {
// We use the DATABASE_URL from Heroku to connect to our DB
connectionString: process.env.DATABASE_URL,
// Heroku also requires this special `ssl` config
ssl: { rejectUnauthorized: false },
};
} else {
// If we're not on heroku, configure PG to use our local database
config = {
host: 'localhost',
port: 5432,
database: 'prime_app', // CHANGE THIS LINE to match your local database name!
};
}Run the following terminal commands from within your project folder's root directory.
heroku git:remote -a project-name- Replace
project-namewith the name of the Heroku app that the client created. - Log in if prompted.
- Replace
git remote -vto ensure it added successfully
Run the following commands from within your project folder's root directory.
heroku pg:push your_database DATABASE_URL- Replace
your_databasewith the actual name of your local PostgreSQL database. - This command effectively pushes up a copy of that database to Heroku.
- If this doesn't work, ensure that you've installed PostgreSQL's CLI Tools and restarted your terminal!
- Replace
git push heroku main- This will push your project repository up to Heroku.
- That's deployment. If everything worked,
heroku openshould successfully open your app in the browser.
heroku logs- Display the most recent Heroku-hosted server logs.heroku logs --tail- Display Heroku-hosted server logs as they occur in real time.
heroku config- Show basic app info.heroku restart- Sometimes it helps to turn things off an on again. 🙂heroku open- Opens the website for you project in the browser.
If you would like to view/edit your hosted database, you can actually use Postico!
- From your Heroku Dashboard, click your application.
- Then, click the Resources tab.
- In the Add-ons section, click Heroku Postgres.
- Click the
Settingstab, then clickView Credentials - Open Postico, then click
New Favorite. - In the new Postico favorite, update the following to match Heroku:
HostDatabaseUserPortPassword
- Click
Connectand you should have access to your database directly from Postico!

