Connect to Render Key Value with ioredis
This guide walks through connecting to a Render Key Value instance with ioredis, the popular Node.js Redis client.
We recommend using the latest version of ioredis. This guide assumes a minimum version of 5.0.0
.
Key Value setup
- Create a Render Key Value instance with these steps.
- Obtain your instance's internal URL from its Connect menu in the Render Dashboard.
- You can use this URL to connect to your instance from your other services in the same region.
If you want to connect to your instance from outside Render (for testing, dev environments, etc.), you also need to enable external connections and add the IP addresses you want to connect from. After you do, you can view your instance's external URL.
Configure ioredis
Next, we'll provide our ioredis client with connection details for our Render Key Value instance.
We strongly recommend storing connection details in environment variables, such as REDIS_URL
.
Connecting via URL
We recommend configuring ioredis by passing in the provided internal or external Key Value URL. When used in Blueprints, you can pass this URL to your services using the fromService
syntax (docs).
Setting detailed connection config
To explicitly configure ioredis you can use the following examples:
Internal connection
External connection
Code examples
Full examples for ioredis of the above are available in our Render Examples repo.