Skip to main content

Deploy a NodeJS app on Heroku using Redis


Profile picture for Ajeet Raina
Author:
Ajeet Raina, Former Developer Growth Manager at Redis

Heroku is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud. It is a platform for data as well as apps - providing a secure, scalable database-as-a-service with tons of developers tools like database followers, forking, dataclips and automated health checks.Heroku is widely popular as it makes the processes of deploying, configuring, scaling, tuning, and managing apps as simple and straightforward as possible, so that developers can focus on what’s most important: building great apps that delight and engage customers.

Step 1. Create Redis Enterprise Cloud

Create your free Redis Enterprise Cloud account by visiting this link

tip

For a limited time, use TIGER200 to get $200 credits on Redis Enterprise Cloud and try all the advanced capabilities!

🎉 Click here to sign up

recloud

Follow this link to create a Redis Enterprise Cloud subscription and database. Once you create the database, you will be provisioned with a unique database endpoint URL, port and password. Save these for future reference.

Step 2. Create a Heroku account

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

heroku

Step 3. Install Heroku CLI on your system

 brew install heroku

Step 4. Login to Heroku

 heroku login
heroku: Press any key to open up the browser to login or q to exit:
Opening browser to https://cli-auth.heroku.com/auth/cli/browser/XXXXXXXXXXA
Logging in... done
Logged in as your_email_address

Step 5. Connect your application to Redis Enterprise Cloud

For this demonstration, we will be using a Sample Rate Limiting application

Clone the repository

 git clone https://github.com/redis-developer/basic-redis-rate-limiting-demo-nodejs

Run the commands below to get a functioning Git repository that contains a simple application as well as a package.json file.

heroku create
Creating app... done, ⬢ rocky-lowlands-06306
https://rocky-lowlands-06306.herokuapp.com/ | https://git.heroku.com/rocky-lowlands-06306.git

Step 6. Setting up environment variables

Go to the Heroku dashboard, click "Settings" and set REDIS_ENDPOINT_URI and REDIS_PASSWORD under the Config Vars. Refer to Step 1 for the correct values to use.

heroku

You now have a functioning Git repository that contains a simple application as well as a package.json file, which is used by Node’s dependency manager.

Step 7. Deploy your code

$ git push heroku

Wait for few seconds and you will see the messages below:

remote: -----> Launching...
remote: Released v3
remote: https://rocky-lowlands-06306.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/rocky-lowlands-06306.git
* [new branch] main -> main

Step 8. Accessing the application

Open https://rocky-lowlands-06306.herokuapp.com/ to see your application

heroku

Next Steps