All eyes on AI: 2026 predictions – The shifts that will shape your stack.

Read now

Tutorial

How to build a NodeJS based application on Heroku using Redis

February 25, 20263 minute read
Ajeet Raina
Ajeet Raina
TL;DR:
Create a Redis Cloud database, install the Heroku CLI, clone a Node.js sample app, set your Redis connection credentials as Heroku config vars, and run git push heroku to deploy. The app connects to Redis Cloud using the REDIS_ENDPOINT_URI and REDIS_PASSWORD environment variables.

#What you'll learn

  • How to create a Redis Cloud database and retrieve connection credentials
  • How to set up a Heroku account and install the Heroku CLI
  • How to configure environment variables in Heroku for Redis Cloud
  • How to deploy a Node.js application to Heroku with git push

#Prerequisites

Note: Heroku no longer offers a free tier. You will need a verified Heroku account with a billing method to complete this tutorial.

#How do I create a Redis Cloud database?

Create your Redis Cloud account. Follow this link to create Redis Cloud subscription and database as shown below:
Redis Cloud subscription and database creation page
Save the database endpoint URL and password for future reference. You will need these values to connect your Heroku app to Redis.

#How do I set up Heroku for a Node.js app?

If you are using Heroku for the first time, create your new Heroku account through this link.
Heroku account sign up page

#Install the Heroku CLI

Install the Heroku CLI so you can deploy from your terminal:

#Log in to Heroku

#How do I connect a Node.js app to Redis Cloud on Heroku?

For this demonstration, we will be using a Sample Rate Limiting application built with Express and the node-redis client.

#Clone the repository

#Create a Heroku app

Run the below CLI to have a functioning Git repository that contains a simple application as well as a package.json file:

#Set Redis environment variables

Go to Heroku dashboard, click "Settings" and set REDIS_ENDPOINT_URI and REDIS_PASSWORD under the Config Vars. Refer to your Redis Cloud database credentials from the first step.
You can also set these from the CLI:
Configuring Redis environment variables in the Heroku settings dashboard

#How do I deploy the Node.js app to Heroku?

Push your code to Heroku to trigger a deployment:
Wait for the build to complete. You will see output similar to:

#Access the running application

Open your app URL to see the deployed application:
Screenshot of the Node.js application running on Heroku

#Next steps