# 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.