# Connecting with keydb-cli

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

## **Variables**

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

</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-07-04 at 4.12.37 PM.jpg](https://docs.elest.io/uploads/images/gallery/2025-07/scaled-1680-/GLuscreenshot-2025-07-04-at-4-12-37-pm.jpg)](https://docs.elest.io/uploads/images/gallery/2025-07/GLuscreenshot-2025-07-04-at-4-12-37-pm.jpg)

## **Prerequisites**

#### **Install <span class="s2">valkey</span>-cli**

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

```bash
valkey-cli --version
```

If not installed, you can install it via:

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

```bash
brew install valkey
```

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

```bash
sudo apt-get install valkey-tools
```

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

Use <span class="s2">**Windows Subsystem for Linux (WSL)**</span> or [download the CLI binaries from the Valkey](https://github.com/valkey-io/valkey/releases?utm_source=chatgpt.com) GitHub releases page.

## **Command**

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

```bash
valkey-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 Valkey service.

If the connection is successful, the terminal will display a Valkey 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 Valkey"
get testkey
```

**Expected output:**

```bash
OK
"Hello Valkey"
```

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