# How to Connect

# Connecting with Node.js

This guide explains how to establish a connection between a Node.js application and a KeyDB 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 KeyDB command.

## **Variables**

To successfully connect to a KeyDB 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);">KeyDB hostname (from Elestio service overview)

</td><td style="width: 53.1585%; border-color: rgb(0, 0, 0);">The address of the server hosting your KeyDB 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);">KeyDB port (from Elestio service overview)

</td><td style="width: 53.1585%; border-color: rgb(0, 0, 0);">The port used for the KeyDB connection. The default KeyDB 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);">KeyDB 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 KeyDB 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-06-26 at 1.13.23 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-06/scaled-1680-/screenshot-2025-06-26-at-1-13-23-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-06/screenshot-2025-06-26-at-1-13-23-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 KeyDB.

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

## **Code**

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

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

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

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

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

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

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

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

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

```
node keydb.js
```

If the connection is successful, the output should resemble:

```
Connected to KeyDB  
Retrieved value: Hello KeyDB
```

# Connecting with Python

This guide explains how to connect a Python application to a KeyDB 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 KeyDB command.

## **Variables**

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

<table border="1" id="bkmrk-variable-description" style="width: 90.8333%; height: 152.781px; 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: 46.5938px;"><td style="width: 12.4672%; height: 46.5938px; border-color: rgb(0, 0, 0);">`HOST`

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

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

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

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

</td><td style="width: 45.2756%; height: 46.5938px; border-color: rgb(0, 0, 0);">Port used to connect to KeyDB. 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);">KeyDB password (from Elestio service overview)

</td><td style="width: 45.2756%; height: 29.7969px; border-color: rgb(0, 0, 0);">Authentication credential for the KeyDB 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-06-26 at 1.13.23 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-06/scaled-1680-/eeqscreenshot-2025-06-26-at-1-13-23-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-06/eeqscreenshot-2025-06-26-at-1-13-23-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">keydb.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 KeyDB")
    value = client.get("testKey")
    print("Connected to KeyDB")
    print("Retrieved value:", value)

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

To execute the script, open the terminal or command prompt and navigate to the directory where `<span class="s1">keydb.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 KeyDB  
Retrieved value: Hello KeyDB
```

# Connecting with PHP

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

## **Variables**

Certain parameters must be provided to establish a successful connection to a KeyDB 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);">KeyDB 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 KeyDB 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 KeyDB 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 KeyDB. 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);">KeyDB 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 KeyDB.

</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-06-26 at 1.13.23 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-06/scaled-1680-/C6oscreenshot-2025-06-26-at-1-13-23-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-06/C6oscreenshot-2025-06-26-at-1-13-23-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 KeyDB. 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">keydb.php</span>` and add the following code:

```php
<?php

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

$keydb = new Redis();

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

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

    echo "Connected to KeyDB\n";

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

    $keydb->close();

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

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

```
php keydb.php
```

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

# Connecting with Go

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

## **Variables**

Certain parameters must be provided to establish a successful connection to a KeyDB 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);">KeyDB 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 KeyDB 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 KeyDB 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 KeyDB. 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);">KeyDB 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 KeyDB.

</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-06-26 at 1.13.23 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-06/scaled-1680-/fcNscreenshot-2025-06-26-at-1-13-23-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-06/fcNscreenshot-2025-06-26-at-1-13-23-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 KeyDB. 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">keydb.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,           
	}

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

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

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

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

	if err := kdbdb.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">keydb.go</span>` is located. Once in the correct directory, run the script with the command:

```bash
go run keydb.go
```

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

```
Connected to KeyDB  
Retrieved value: Hello KeyDB
```

# Connecting with Java

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

## **Variables**

Certain parameters must be provided to establish a successful connection to a KeyDB 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);">KeyDB 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 KeyDB 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 KeyDB 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 KeyDB. 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);">KeyDB 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 KeyDB.

</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-06-26 at 1.13.23 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-06/scaled-1680-/Jd1screenshot-2025-06-26-at-1-13-23-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-06/Jd1screenshot-2025-06-26-at-1-13-23-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 KeyDB. 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 KeyDBTest<span class="s2">.java</span> and add the following code:

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

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

        JedisPooled jedis = new JedisPooled(host, port, password);

        try {
            jedis.set("testKey", "Hello KeyDB");
            String value = jedis.get("testKey");

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

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

To execute the script, open the terminal or command prompt and navigate to the directory where KeyDB<span class="s1">Test.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" KeyDBTest.java
java -cp ".:jedis-5.1.0.jar:commons-pool2-2.11.1.jar" KeyDBTest
```

**On Windows :**

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

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

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

# Connecting with RedisInsight

This guide explains how to establish a connection between RedisInsight and a KeyDB 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 KeyDB 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);">KeyDB 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 KeyDB 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 KeyDB 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 KeyDB. 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);">KeyDB 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 KeyDB.

</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-06-26 at 1.13.23 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-06/scaled-1680-/SwMscreenshot-2025-06-26-at-1-13-23-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-06/SwMscreenshot-2025-06-26-at-1-13-23-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 KeyDB Database**
    
    <span class="s1">Click on </span>**“Add KeyDB Database”**<span class="s1">.</span>
3. **Enter Your Connection Details**
    
    Fill in the following fields using your Elestio KeyDB 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 KeyDB using a built-in CLI or visual browser.

# Connecting with keydb-cli

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

## **Variables**

Certain parameters must be provided to establish a successful connection to a KeyDB 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="border-collapse: collapse; border-color: rgb(0, 0, 0); width: 100%;"><thead><tr><th style="border-color: rgb(0, 0, 0); width: 12.1551%;">**Variable**

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

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

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

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

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

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

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

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

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

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

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

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

These values can usually be found in the <span class="s1">**Elestio service overview**</span> 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-06-26 at 1.13.23 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-06/scaled-1680-/z11screenshot-2025-06-26-at-1-13-23-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-06/z11screenshot-2025-06-26-at-1-13-23-pm.jpg)

## **Prerequisites**

#### **Install keydb-cli**

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

```bash
keydb-cli --version
```

If not installed, you can install it via:

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

```bash
brew install keydb
```

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

```bash
sudo add-apt-repository ppa:keydb/keydb
sudo apt-get update
sudo apt-get install keydb-tools
```

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

Use <span class="s2">**Windows Subsystem for Linux (WSL)**</span> or [download the CLI binaries from the KeyDB GitHub releases page](https://github.com/Snapchat/KeyDB/releases).

## **Command**

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

```bash
keydb-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 KeyDB service.

If the connection is successful, the terminal will display a KeyDB prompt like this:

```bash
127.0.0.1:6379>
```

**Test the Connection**

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

```bash
set testkey "Hello KeyDB"
get testkey
```

**Expected output:**

```bash
OK
"Hello KeyDB"
```

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