For AI agents: the complete documentation index is available at https://docs.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.ovhcloud.com/en/llms-full.txt, and this page is available as Markdown at https://docs.ovhcloud.com/en/guides/public-cloud/databases/valkey-connect-cli.md.

Connect using the CLI for Public Cloud Databases for Valkey

View as Markdown

Connect to your Public Cloud Databases for Valkey using the Command Line Interface (CLI)

Objective

Public Cloud Databases allow you to focus on building and deploying cloud applications while OVHcloud takes care of the database infrastructure and maintenance in operational conditions.

This guide explains how to connect to a Valkey service instance with a Command Line Interface (CLI).

Requirements

Concept

You can manage a Valkey service in several ways. One of the easiest, yet powerful, is to use a Command Line Interface (CLI), also known as a Console or Terminal. To interact correctly with the instance, we need to first install something called a client, in order to connect and control the Valkey service remotely. It's a Client-Server interaction.

Instructions

Installing valkey-cli on your client

Info

valkey-cli is the official Valkey client. It is shipped with the Valkey packages.

You first need to install a software to interact with your instance remotely. This official software can be installed on various supports like your own computer, a VPS, a virtual machine... The only rule is to be able to reach the public network (Internet) and have sufficient privilege to install it.

Depending on your operating system:

  • macOS (Homebrew): brew install valkey
  • Debian / Ubuntu: sudo apt install valkey-tools (Debian 13 or later, Debian 12 with bookworm-backports, Ubuntu 24.04 or later; not available on Ubuntu 22.04)
  • Fedora / RHEL: sudo dnf install valkey
  • Alpine Linux: apk add valkey-cli
  • Docker: the official valkey/valkey image contains valkey-cli, for example docker run -it --rm valkey/valkey valkey-cli --version.
  • Windows: valkey-cli is not available natively. Use it from WSL (with one of the Linux commands above) or from Docker.

For other installation methods, refer to the official Valkey installation documentation.

Check that the client is installed:

$ valkey-cli --version
valkey-cli 9.1.2

The version number depends on your package. Your client must support TLS, which is the case for the packages listed above. valkeys:// URIs require valkey-cli 8.0 or later. With an older version (Ubuntu 24.04 installs 7.2), replace valkeys:// with rediss://.

Info

redis-cli and other Redis-compatible clients can also connect to your Valkey service. redis-cli does not accept the valkeys:// scheme: use rediss:// instead, for example redis-cli --tls -u rediss://<username>:<password>@<host>:<port> PING.

We are now ready to learn how to connect to our instance.

Connection

Get the host, the port and the URI of your service in the Dashboard tab, Connection information section, as explained in the Configure incoming connections guide.

Warning

TLS is mandatory: connections without TLS are refused. Always use the valkeys:// scheme (or the --tls option). The server certificate is signed by a public certification authority, so you do not need to download a CA certificate or to add a --cacert option.

In your terminal, type:

valkey-cli --tls -u valkeys://<username>:<password>@<host>:<port> PING

Don't forget you need to modify the username, password, host and port.

The result should look like this:

$ valkey-cli --tls -u valkeys://<username>:<password>@<host>:<port> PING
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
PONG

It means that the instance is running and responding to your command.

To be in interactive mode, run the same command without any Valkey command at the end:

valkey-cli --tls -u valkeys://<username>:<password>@<host>:<port>

In our example, it will look like this:

$ valkey-cli --tls -u valkeys://<username>:<password>@<host>:<port>
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
<host>:<port>> PING
PONG
<host>:<port>> HELLO
 1) "server"
 2) "valkey"
 3) "version"
 4) "9.1.2"
 5) "proto"
 6) (integer) 2
 7) "id"
 8) (integer) 85
 9) "mode"
10) "standalone"
11) "role"
12) "master"
13) "modules"
...
<host>:<port>> SET cache:greeting "hello"
OK
<host>:<port>> GET cache:greeting
"hello"
<host>:<port>> DEL cache:greeting
(integer) 1

Congratulations! You are now fully able to interact with your instance!

Tip

Use PING or HELLO to test a connection. INFO is refused to users whose permissions do not include it.

Avoiding the password on the command line

With the -u option, the password stays in your shell history and is visible in the list of processes, hence the warning displayed by valkey-cli. To avoid it, use one of these methods:

  • Connect without credentials, then authenticate inside the interactive session:

    $ valkey-cli --tls -h <host> -p <port>
    <host>:<port>> AUTH <username> <password>
    OK
  • Let valkey-cli prompt for the password, which is not displayed:

    $ valkey-cli --tls -h <host> -p <port> --user <username> --askpass
    Please input password:
Warning

Do not put only the username in the URI (valkeys://<username>@<host>:<port>): valkey-cli reads the value before @ as a password, and authentication fails.

valkey-cli usage

You can manage your instance using the command line interface in interactive mode or by setting parameters as valkey-cli arguments.

Please follow the official valkey-cli documentation and the list of Valkey commands.

In the event of connection or command execution issues

If you do not authenticate, every command is refused with a NOAUTH error:

$ valkey-cli --tls -h <host> -p <port> PING
(error) NOAUTH Authentication required.

If the username or the password is wrong, authentication fails with a WRONGPASS error:

WRONGPASS invalid username-password pair or user is disabled.

Check the username in the Users tab of your service. The password is displayed only once, at creation: if you lost it, reset it from the Users tab.

If the user is authenticated but its permissions (ACL) do not allow the key, the command or the channel, you get a NOPERM response:

<host>:<port>> GET foo
(error) NOPERM No permissions to access a key

In this case, review the keys, categories, commands and channels allowed for your user, in the Users tab or with the API. For more information, see the official Valkey ACL documentation.

Go further

Valkey capabilities and limitations

Configuring vRack for Public Cloud

Visit the Github examples repository to find how to connect to your database with several languages.

We want your feedback!

We would love to help answer questions and appreciate any feedback you may have.

For training or technical assistance implementing our solutions, contact your sales representative or visit our Professional Services page to request a quote and have your project analysed by our experts.

Are you on Discord? Connect to our channel at https://discord.gg/ovhcloud and interact directly with the team that builds our databases service!

Was this page helpful?