# How to Connect

# Connecting with Node.js

This guide explains how to establish a connection between a Node.js application and a Redis database using the [<span class="s2">redis</span>](https://www.npmjs.com/package/redis) package. It walks through the necessary setup, configuration, and execution of a simple Redis command.

## **Variables**

To successfully connect to a Redis instance, you’ll need to provide the following parameters. These can typically be found on the Elestio service overview page.

<table border="1" id="bkmrk-variable-description" style="width: 100%; border-collapse: collapse; border-color: rgb(0, 0, 0);"><thead><tr><th style="width: 12.2747%; border-color: rgb(0, 0, 0);">**Variable**

</th><th style="width: 34.5668%; border-color: rgb(0, 0, 0);">**Description**

</th><th style="width: 53.1585%; border-color: rgb(0, 0, 0);">**Purpose**

</th></tr></thead><tbody><tr><td style="width: 12.2747%; border-color: rgb(0, 0, 0);">`HOST`

</td><td style="width: 34.5668%; border-color: rgb(0, 0, 0);">Redis hostname (from Elestio service overview)

</td><td style="width: 53.1585%; border-color: rgb(0, 0, 0);">The address of the server hosting your Redis instance.

</td></tr><tr><td style="width: 12.2747%; border-color: rgb(0, 0, 0);">`PORT`

</td><td style="width: 34.5668%; border-color: rgb(0, 0, 0);">Redis port (from Elestio service overview)

</td><td style="width: 53.1585%; border-color: rgb(0, 0, 0);">The port used for the Redis connection. The default Redis port is 6379.

</td></tr><tr><td style="width: 12.2747%; border-color: rgb(0, 0, 0);">`PASSWORD`

</td><td style="width: 34.5668%; border-color: rgb(0, 0, 0);">Redis password (from Elestio service overview)

</td><td style="width: 53.1585%; border-color: rgb(0, 0, 0);">Authentication key used to connect securely to the Redis instance.

</td></tr></tbody></table>

These values can usually be found in the Elestio service overview details as shown in the image below, make sure to take a copy of these details and add it to the code moving ahead.

[![Screenshot 2025-05-19 at 12.23.05 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-05/scaled-1680-/screenshot-2025-05-19-at-12-23-05-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-05/screenshot-2025-05-19-at-12-23-05-pm.jpg)

## **Prerequisites**

**Install Node.js and NPM**

- Check if Node.js is installed by running:

```
node -v
```

- If not installed, download and install it from [nodejs.org](https://nodejs.org).
- Confirm <span class="s1">npm</span> is installed by running:

```
npm -v
```

**Install the redis Package**

The <span class="s2">redis</span> package enables communication between Node.js applications and Redis.

```
npm install redis --save
```

## **Code**

Create a new file named `<span class="s2">redis.js</span>` and add the following code:

```javascript
const redis = require("redis");

// Redis connection configuration
const config = {
  socket: {
    host: "HOST",
    port: PORT,
  },
  password: "PASSWORD",
};

// Create a Redis client
const client = redis.createClient(config);

// Handle connection errors
client.on("error", (err) => {
  console.error("Redis connection error:", err);
});

// Connect and run a test command
(async () => {
  try {
    await client.connect();
    console.log("Connected to Redis");

    // Set and retrieve a test key
    await client.set("testKey", "Hello Redis");
    const value = await client.get("testKey");
    console.log("Retrieved value:", value);

    // Disconnect from Redis
    await client.disconnect();
  } catch (err) {
    console.error("Redis operation failed:", err);
  }
})();
```

To execute the script, open the terminal or command prompt and navigate to the directory where `<span class="s1">redis.js</span>` is located. Once in the correct directory, run the script with the command:

```
node redis.js
```

If the connection is successful, the output should resemble:

```
Connected to Redis  
Retrieved value: Hello Redis
```

# Connecting with Python

This guide explains how to connect a Python application to a Redis database using the [<span class="s3">redis</span>](https://pypi.org/project/redis/) library. It walks through the required setup, configuration, and execution of a simple Redis command.

## **Variables**

To connect to Redis, the following parameters are needed. You can find these values in the Elestio Redis service overview.

<table border="1" id="bkmrk-variable-description" style="width: 90.8333%; height: 119.188px; border-collapse: collapse; border-width: 1px; border-color: rgb(0, 0, 0);"><thead><tr style="height: 29.7969px;"><th style="width: 12.4672%; height: 29.7969px; border-color: rgb(0, 0, 0);">**Variable**

</th><th style="width: 42.3885%; height: 29.7969px; border-color: rgb(0, 0, 0);">**Description**

</th><th style="width: 45.2756%; height: 29.7969px; border-color: rgb(0, 0, 0);">**Purpose**

</th></tr></thead><tbody><tr style="height: 29.7969px;"><td style="width: 12.4672%; height: 29.7969px; border-color: rgb(0, 0, 0);">`HOST`

</td><td style="width: 42.3885%; height: 29.7969px; border-color: rgb(0, 0, 0);">Redis hostname (from Elestio service overview)

</td><td style="width: 45.2756%; height: 29.7969px; border-color: rgb(0, 0, 0);">Address of the Redis server.

</td></tr><tr style="height: 29.7969px;"><td style="width: 12.4672%; height: 29.7969px; border-color: rgb(0, 0, 0);">`PORT`

</td><td style="width: 42.3885%; height: 29.7969px; border-color: rgb(0, 0, 0);">Redis port (from Elestio service overview)

</td><td style="width: 45.2756%; height: 29.7969px; border-color: rgb(0, 0, 0);">Port used to connect to Redis. The default is <span class="s1">6379</span>.

</td></tr><tr style="height: 29.7969px;"><td style="width: 12.4672%; height: 29.7969px; border-color: rgb(0, 0, 0);">`PASSWORD`

</td><td style="width: 42.3885%; height: 29.7969px; border-color: rgb(0, 0, 0);">Redis password (from Elestio service overview)

</td><td style="width: 45.2756%; height: 29.7969px; border-color: rgb(0, 0, 0);">Authentication credential for the Redis connection.

</td></tr></tbody></table>

These values can usually be found in the Elestio service overview details as shown in the image below, make sure to take a copy of these details and add it to the code moving ahead.

[![Screenshot 2025-05-19 at 12.23.05 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-05/scaled-1680-/screenshot-2025-05-19-at-12-23-05-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-05/screenshot-2025-05-19-at-12-23-05-pm.jpg)

## **Prerequisites**

**Install Python and pip**

- Check if Python is installed by running:

```
python3 --version
```

- If not installed, download and install it from [python.org](https://www.python.org).
- Check pip (Python package installer):

```
pip --version
```

**Install the redis Package**

Install the official <span class="s2">redis</span> library using pip:

```
pip install redis
```

## **Code**

Create a file named `<span class="s2">redis.py</span>` and paste the following code:

```python
import redis

config = {
    "host": "HOST",
    "port": PORT,  # Example: 6379
    "password": "PASSWORD",
    "decode_responses": True
}

try:
    client = redis.Redis(**config)
    client.set("testKey", "Hello Redis")
    value = client.get("testKey")
    print("Connected to Redis")
    print("Retrieved value:", value)

except redis.RedisError as err:
    print("Redis connection or operation failed:", err)
```

To execute the script, open the terminal or command prompt and navigate to the directory where `<span class="s1">redis.py</span>` is located. Once in the correct directory, run the script with the command:

```
python3 redis.py
```

If everything is set up correctly, the output will be:

```
Connected to Redis  
Retrieved value: Hello Redis
```

# Connecting with PHP

This guide explains how to establish a connection between a PHP application and a Redis database using the <span class="s3">phpredis</span> extension. It walks through the necessary setup, configuration, and execution of a simple Redis command.

## **Variables**

Certain parameters must be provided to establish a successful connection to a Redis database. Below is a breakdown of each required variable, its purpose, and where to find it. Here’s what each variable represents:

<table border="1" id="bkmrk-variable-description" style="width: 100%; border-collapse: collapse; border-color: rgb(0, 0, 0);"><thead><tr><th style="width: 11.3214%; border-color: rgb(0, 0, 0);">**Variable**

</th><th style="width: 42.6714%; border-color: rgb(0, 0, 0);">**Description**

</th><th style="width: 46.1263%; border-color: rgb(0, 0, 0);">**Purpose**

</th></tr></thead><tbody><tr><td style="width: 11.3214%; border-color: rgb(0, 0, 0);">`HOST`

</td><td style="width: 42.6714%; border-color: rgb(0, 0, 0);">Redis hostname, from the Elestio service overview page

</td><td style="width: 46.1263%; border-color: rgb(0, 0, 0);">The address of the server hosting your Redis instance.

</td></tr><tr><td style="width: 11.3214%; border-color: rgb(0, 0, 0);">`PORT`

</td><td style="width: 42.6714%; border-color: rgb(0, 0, 0);">Port for Redis connection, from the Elestio service overview page

</td><td style="width: 46.1263%; border-color: rgb(0, 0, 0);">The network port used to connect to Redis. The default port is 6379.

</td></tr><tr><td style="width: 11.3214%; border-color: rgb(0, 0, 0);">`PASSWORD`

</td><td style="width: 42.6714%; border-color: rgb(0, 0, 0);">Redis password, from the Elestio service overview page

</td><td style="width: 46.1263%; border-color: rgb(0, 0, 0);">The authentication key required to connect securely to Redis.

</td></tr></tbody></table>

These values can usually be found in the Elestio service overview details as shown in the image below. Make sure to take a copy of these details and add it to the code moving ahead.

[![Screenshot 2025-05-19 at 12.23.05 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-05/scaled-1680-/screenshot-2025-05-19-at-12-23-05-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-05/screenshot-2025-05-19-at-12-23-05-pm.jpg)

## **Prerequisites**

- **Install PHP**
    - Check if PHP is installed by running:

```
php -v
```

- - If not installed, download it from [php.net](https://www.php.net/downloads) and install.
- **Install the phpredis Extension**
    - The <span class="s2">phpredis</span> extension provides a native PHP interface for Redis. You can install it using:

```
sudo pecl install redis
```

- - Then enable it in your <span class="s1">php.ini</span>:

```
extension=redis
```

- - To verify it’s installed:

```
php -m | grep redis
```

## **Code**

Once all prerequisites are set up, create a new file named `<span class="s2">redis.php</span>` and add the following code:

```php
<?php

$host = 'HOST';
$port = PORT;
$password = 'PASSWORD';

$redis = new Redis();

try {
    $redis->connect($host, $port);

    if (!$redis->auth($password)) {
        throw new Exception('Authentication failed');
    }

    echo "Connected to Redis\n";

    $redis->set("testKey", "Hello Redis");
    $value = $redis->get("testKey");
    echo "Retrieved value: $value\n";

    $redis->close();

} catch (Exception $e) {
    echo "Redis connection or operation failed: " . $e->getMessage() . "\n";
}
```

Open the terminal or command prompt and navigate to the directory where `<span class="s2">redis.php</span>` is located. Once in the correct directory, run the script with the command:

```
php redis.php
```

If the connection is successful, the terminal will display output similar to:

```
Connected to Redis  
Retrieved value: Hello Redis
```

# Connecting with Go

This guide explains how to establish a connection between a Go application and a Redis database using the <span class="s3">go-redis</span> package. It walks through the necessary setup, configuration, and execution of a simple Redis command.

## **Variables**

Certain parameters must be provided to establish a successful connection to a Redis database. Below is a breakdown of each required variable, its purpose, and where to find it. Here’s what each variable represents:

<table border="1" id="bkmrk-variable-description" style="width: 100%; border-collapse: collapse; border-color: rgb(0, 0, 0);"><thead><tr><th style="width: 10.7246%; border-color: rgb(0, 0, 0);">**Variable**

</th><th style="width: 42.5531%; border-color: rgb(0, 0, 0);">**Description**

</th><th style="width: 46.7223%; border-color: rgb(0, 0, 0);">**Purpose**

</th></tr></thead><tbody><tr><td style="width: 10.7246%; border-color: rgb(0, 0, 0);">`HOST`

</td><td style="width: 42.5531%; border-color: rgb(0, 0, 0);">Redis hostname, from the Elestio service overview page

</td><td style="width: 46.7223%; border-color: rgb(0, 0, 0);">The address of the server hosting your Redis instance.

</td></tr><tr><td style="width: 10.7246%; border-color: rgb(0, 0, 0);">`PORT`

</td><td style="width: 42.5531%; border-color: rgb(0, 0, 0);">Port for Redis connection, from the Elestio service overview page

</td><td style="width: 46.7223%; border-color: rgb(0, 0, 0);">The network port used to connect to Redis. The default port is 6379.

</td></tr><tr><td style="width: 10.7246%; border-color: rgb(0, 0, 0);">`PASSWORD`

</td><td style="width: 42.5531%; border-color: rgb(0, 0, 0);">Redis password, from the Elestio service overview page

</td><td style="width: 46.7223%; border-color: rgb(0, 0, 0);">The authentication key required to connect securely to Redis.

</td></tr></tbody></table>

These values can usually be found in the Elestio service overview details as shown in the image below, make sure to take a copy of these details and add it to the code moving ahead.

[![Screenshot 2025-05-19 at 12.23.05 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-05/scaled-1680-/screenshot-2025-05-19-at-12-23-05-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-05/screenshot-2025-05-19-at-12-23-05-pm.jpg)

## **Prerequisites**

**Install Go**

Check if Go is installed by running:

```bash
go version
```

If not installed, download it from golang.org and install.

**Install the go-redis Package**

The <span class="s2">go-redis</span> package enables Go applications to interact with Redis. Install it using:

```bash
go get github.com/redis/go-redis/v9
```

## **Code**

Once all prerequisites are set up, create a new file named `<span class="s2">redis.go</span>` and add the following code:

```go
package main

import (
	"context"
	"fmt"
	"time"

	"github.com/redis/go-redis/v9"
)

func main() {
	opt := &redis.Options{
		Addr:     "HOST:PORT",     
		Password: "PASSWORD",      
		DB:       0,           
	}

	rdb := redis.NewClient(opt)
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()

	err := rdb.Set(ctx, "testKey", "Hello Redis", 0).Err()
	if err != nil {
		fmt.Println("Redis operation failed:", err)
		return
	}

	val, err := rdb.Get(ctx, "testKey").Result()
	if err != nil {
		fmt.Println("Redis operation failed:", err)
		return
	}

	fmt.Println("Connected to Redis")
	fmt.Println("Retrieved value:", val)

	if err := rdb.Close(); err != nil {
		fmt.Println("Error closing connection:", err)
	}
}
```

To execute the script, open the terminal or command prompt and navigate to the directory where `<span class="s1">redis.go</span>` is located. Once in the correct directory, run the script with the command:

```bash
go run redis.go
```

If the connection is successful, the terminal will display output similar to:

```
Connected to Redis  
Retrieved value: Hello Redis
```

# Connecting with Java

This guide explains how to establish a connection between a Java application and a Redis database using the <span class="s3">Jedis</span> library. It walks through the necessary setup, configuration, and execution of a simple Redis command.

## **Variables**

Certain parameters must be provided to establish a successful connection to a Redis database. Below is a breakdown of each required variable, its purpose, and where to find it. Here’s what each variable represents:

<table border="1" id="bkmrk-variable-description" style="width: 100%; border-collapse: collapse; border-color: rgb(0, 0, 0);"><thead><tr><th style="width: 11.5595%; border-color: rgb(0, 0, 0);">**Variable**

</th><th style="width: 42.4333%; border-color: rgb(0, 0, 0);">**Description**

</th><th style="width: 46.1263%; border-color: rgb(0, 0, 0);">**Purpose**

</th></tr></thead><tbody><tr><td style="width: 11.5595%; border-color: rgb(0, 0, 0);">`HOST`

</td><td style="width: 42.4333%; border-color: rgb(0, 0, 0);">Redis hostname, from the Elestio service overview page

</td><td style="width: 46.1263%; border-color: rgb(0, 0, 0);">The address of the server hosting your Redis instance.

</td></tr><tr><td style="width: 11.5595%; border-color: rgb(0, 0, 0);">`PORT`

</td><td style="width: 42.4333%; border-color: rgb(0, 0, 0);">Port for Redis connection, from the Elestio service overview page

</td><td style="width: 46.1263%; border-color: rgb(0, 0, 0);">The network port used to connect to Redis. The default port is 6379.

</td></tr><tr><td style="width: 11.5595%; border-color: rgb(0, 0, 0);">`PASSWORD`

</td><td style="width: 42.4333%; border-color: rgb(0, 0, 0);">Redis password, from the Elestio service overview page

</td><td style="width: 46.1263%; border-color: rgb(0, 0, 0);">The authentication key required to connect securely to Redis.

</td></tr></tbody></table>

These values can usually be found in the Elestio service overview details as shown in the image below, make sure to take a copy of these details and add it to the code moving ahead.

[![Screenshot 2025-05-19 at 12.23.05 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-05/scaled-1680-/screenshot-2025-05-19-at-12-23-05-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-05/screenshot-2025-05-19-at-12-23-05-pm.jpg)

## **Prerequisites**

**Install Java**

Check if Java is installed by running:

```
java -version
```

If not installed, download it from oracle.com and install.

**Download Jedis and Dependencies**

The Jedis library enables Java applications to interact with Redis. You need to download two JAR files manually:

1. <span class="s1">**Jedis JAR**</span> (Jedis 5.1.0):
    
    [https://repo1.maven.org/maven2/redis/clients/jedis/5.1.0/jedis-5.1.0.jar](https://repo1.maven.org/maven2/redis/clients/jedis/5.1.0/jedis-5.1.0.jar)
2. **Apache Commons Pool2 JAR**<span class="s1"> (Required by Jedis):</span>
    
    [https://repo1.maven.org/maven2/org/apache/commons/commons-pool2/2.11.1/commons-pool2-2.11.1.jar](https://repo1.maven.org/maven2/org/apache/commons/commons-pool2/2.11.1/commons-pool2-2.11.1.jar)

Place both JAR files in the same directory as your Java file.

## **Code**

Once all prerequisites are set up, create a new file named <span class="s2">RedisTest.java</span> and add the following code:

```java
import redis.clients.jedis.JedisPooled;

public class RedisTest {
    public static void main(String[] args) {
        // Redis connection configuration
        String host = "HOST";
        int port = PORT; // e.g., 6379
        String password = "PASSWORD";

        // Create a Redis client
        JedisPooled jedis = new JedisPooled(host, port, password);

        try {
            // Set and get a test key
            jedis.set("testKey", "Hello Redis");
            String value = jedis.get("testKey");

            System.out.println("Connected to Redis");
            System.out.println("Retrieved value: " + value);

        } catch (Exception e) {
            System.out.println("Redis connection or operation failed: " + e.getMessage());
        }
    }
}
```

To execute the script, open the terminal or command prompt and navigate to the directory where <span class="s1">RedisTest.java</span> is located. Once in the correct directory, run the following commands:

**On Linux/macOS :**

```bash
javac -cp "jedis-5.1.0.jar:commons-pool2-2.11.1.jar" RedisTest.java
java -cp ".:jedis-5.1.0.jar:commons-pool2-2.11.1.jar" RedisTest
```

**On Windows :**

```bash
javac -cp "jedis-5.1.0.jar;commons-pool2-2.11.1.jar" RedisTest.java
java -cp ".;jedis-5.1.0.jar;commons-pool2-2.11.1.jar" RedisTest
```

If the connection is successful, the terminal will display output similar to:

```bash
Connected to Redis  
Retrieved value: Hello Redis
```

# Connecting with RedisInsight

This guide explains how to establish a connection between RedisInsight and a Redis database instance. It walks through the necessary setup, configuration, and connection steps using the official Redis GUI.

## **Variables**

Certain parameters must be provided to establish a successful connection to a Redis database. Below is a breakdown of each required variable, its purpose, and where to find it. Here’s what each variable represents:

<table border="1" id="bkmrk-variable-description" style="width: 100%; border-collapse: collapse; border-color: rgb(0, 0, 0);"><thead><tr><th style="width: 11.7976%; border-color: rgb(0, 0, 0);">**Variable**

</th><th style="width: 42.1952%; border-color: rgb(0, 0, 0);">**Description**

</th><th style="width: 46.1263%; border-color: rgb(0, 0, 0);">**Purpose**

</th></tr></thead><tbody><tr><td style="width: 11.7976%; border-color: rgb(0, 0, 0);">`HOST`

</td><td style="width: 42.1952%; border-color: rgb(0, 0, 0);">Redis hostname, from the Elestio service overview page

</td><td style="width: 46.1263%; border-color: rgb(0, 0, 0);">The address of the server hosting your Redis instance.

</td></tr><tr><td style="width: 11.7976%; border-color: rgb(0, 0, 0);">`PORT`

</td><td style="width: 42.1952%; border-color: rgb(0, 0, 0);">Port for Redis connection, from the Elestio service overview page

</td><td style="width: 46.1263%; border-color: rgb(0, 0, 0);">The network port used to connect to Redis. The default port is 6379.

</td></tr><tr><td style="width: 11.7976%; border-color: rgb(0, 0, 0);">`PASSWORD`

</td><td style="width: 42.1952%; border-color: rgb(0, 0, 0);">Redis password, from the Elestio service overview page

</td><td style="width: 46.1263%; border-color: rgb(0, 0, 0);">The authentication key required to connect securely to Redis.

</td></tr></tbody></table>

These values can usually be found in the Elestio service overview details as shown in the image below, make sure to take a copy of these details and add it to the tool moving ahead.

[![Screenshot 2025-05-19 at 12.23.05 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-05/scaled-1680-/screenshot-2025-05-19-at-12-23-05-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-05/screenshot-2025-05-19-at-12-23-05-pm.jpg)

## **Prerequisites**

**Install RedisInsight**

RedisInsight is a graphical tool for managing Redis databases. Download and install RedisInsight from:

[https://redis.com/redis-enterprise/redis-insight/](https://redis.com/redis-enterprise/redis-insight/)

RedisInsight is available for Windows, macOS, and Linux.

## **Steps**

Once all prerequisites are set up, follow these steps to connect:

1. **Launch RedisInsight**
    
    Open the RedisInsight application after installation.
2. **Add a New Redis Database**
    
    <span class="s1">Click on </span>**“Add Redis Database”**<span class="s1">.</span>
3. **Enter Your Connection Details**
    
    Fill in the following fields using your Elestio Redis service information:
    
    
    - **Host**<span class="s1">: </span><span class="s2">HOST</span>
    - **Port**<span class="s1">: </span><span class="s2">PORT</span>
    - **Password**<span class="s1">: </span><span class="s2">PASSWORD</span>
    
    [![image.png](https://docs.elest.io/uploads/images/gallery/2025-05/scaled-1680-/0Huimage.png)](https://docs.elest.io/uploads/images/gallery/2025-05/0Huimage.png)
4. **Test and Save the Connection**
    
    Click on <span class="s1">**“Test Connection”**</span> to verify the details. If successful, click <span class="s1">**“Connect”**</span> or <span class="s1">**“Add Database”**</span>.

If the connection is successful, RedisInsight will display a dashboard showing key metrics, data structures, memory usage, and allow you to interact directly with Redis using a built-in CLI or visual browser.

# Connecting with redis-cli

This guide explains how to establish a connection between <span class="s3">redis-cli</span> and a Redis database instance. It walks through the necessary setup, configuration, and execution of a simple Redis command from the terminal.

## **Variables**

Certain parameters must be provided to establish a successful connection to a Redis database. Below is a breakdown of each required variable, its purpose, and where to find it. Here’s what each variable represents:

<table border="1" id="bkmrk-variable-description" style="width: 100%; border-collapse: collapse; border-color: rgb(0, 0, 0);"><thead><tr><th style="width: 12.1573%; border-color: rgb(0, 0, 0);">**Variable**

</th><th style="width: 41.8355%; border-color: rgb(0, 0, 0);">**Description**

</th><th style="width: 46.1263%; border-color: rgb(0, 0, 0);">**Purpose**

</th></tr></thead><tbody><tr><td style="width: 12.1573%; border-color: rgb(0, 0, 0);">`HOST`

</td><td style="width: 41.8355%; border-color: rgb(0, 0, 0);">Redis hostname, from the Elestio service overview page

</td><td style="width: 46.1263%; border-color: rgb(0, 0, 0);">The address of the server hosting your Redis instance.

</td></tr><tr><td style="width: 12.1573%; border-color: rgb(0, 0, 0);">`PORT`

</td><td style="width: 41.8355%; border-color: rgb(0, 0, 0);">Port for Redis connection, from the Elestio service overview page

</td><td style="width: 46.1263%; border-color: rgb(0, 0, 0);">The network port used to connect to Redis. The default port is 6379.

</td></tr><tr><td style="width: 12.1573%; border-color: rgb(0, 0, 0);">`PASSWORD`

</td><td style="width: 41.8355%; border-color: rgb(0, 0, 0);">Redis password, from the Elestio service overview page

</td><td style="width: 46.1263%; border-color: rgb(0, 0, 0);">The authentication key required to connect securely to Redis.

</td></tr></tbody></table>

These values can usually be found in the Elestio service overview details as shown in the image below, make sure to take a copy of these details and use them in the command moving ahead.

[![Screenshot 2025-05-19 at 12.23.05 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-05/scaled-1680-/screenshot-2025-05-19-at-12-23-05-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-05/screenshot-2025-05-19-at-12-23-05-pm.jpg)

## **Prerequisites**

**Install redis-cli**

Check if <span class="s2">redis-cli</span> is installed by running:

```
redis-cli --version
```

If not installed, you can install it via:

- **macOS**<span class="s1">:</span>

```
brew install redis
```

- **Ubuntu/Debian**<span class="s1">:</span>

```
sudo apt install redis-tools
```

- **Windows**<span class="s1">:</span>
    
    Use Windows Subsystem for Linux (WSL) or download a Redis CLI binary.

## **Command**

Once all prerequisites are set up, open the terminal or command prompt and run the following command:

```bash
redis-cli -h HOST -p PORT -a PASSWORD
```

Replace <span class="s1">HOST</span>, <span class="s1">PORT</span>, and <span class="s1">PASSWORD</span> with the actual values from your Elestio Redis service. If the connection is successful, the terminal will display a Redis prompt like this:

```
HOST:PORT>
```

You can then run a simple command to test the connection:

```
set testKey "Hello Redis"
get testKey
```

Expected output:

```
"Hello Redis"
```

If the connection is successful, the terminal will display output similar to:

```
"Hello Redis"
```