Skip to content
Ubuntu Linux

How to Install Valkey on Ubuntu 24.04

Richard
Written by
Richard
Updated 5 min read
How to Install Valkey on Ubuntu 24.04
How to Install Valkey on Ubuntu 24.04

Valkey on Ubuntu 24.04 installs through the standard terminal package manager in just a few minutes. Valkey is a fast open-source database that holds information in computer memory as key-value pairs to speed up web apps.

Originally started as a fork of Redis, the software lets you cache web pages, save user login sessions, and handle real-time data queues. You only need a clean Ubuntu 24.04 system with administrator access to get the database running. In practice that means a user account that can run commands with sudo, plus a working internet connection so the package manager can download the files.

⚡ Quick Answer

Install Valkey on Ubuntu 24.04 by first updating your package list with `sudo apt update`. Then, install Valkey using the command `sudo apt install valkey`. This will add Valkey to your system from the default repositories.

Advertisement

Install Valkey on Ubuntu

Before installing Valkey, update Ubuntu, then install Valkey. You don’t have to add any extra repositories, because Valkey’s packages are included in Ubuntu’s default repositories.

Open a terminal and run the update command in the first block below. It refreshes the package list, so you get the newest version Ubuntu offers. Then run the install command in the next block. Type your password if sudo asks for it. You may be asked to confirm the download. If so, type Y and press Enter.

Advertisement
🐧Bash / Shell
sudo apt update
sudo apt install valkey

When the install finishes, the terminal returns to the prompt without errors. If you see an error saying the package cannot be found, run the update command again and check that your internet connection works. Once installed, the configuration file is located at /etc/valkey/valkey.conf. You will edit this file in the next section.

Configure Valkey

To configure Valkey on Ubuntu, open the main settings file located at /etc/valkey/valkey.conf using a text editor like nano. This configuration file lets you change important settings, such as restricting server connections or updating passwords, to keep your database secure and running the way you want.

You need sudo to open the file for editing, because it is owned by the system and a normal user can only read it. Run the command in the block below. The editor opens with the file contents on screen.

🐧Bash / Shell
sudo nano /etc/valkey/valkey.conf

Adjust settings based on your environment. Use the arrow keys to scroll through the file. Most lines are comments that explain what each option does, so read them before changing anything. Two kinds of settings matter most:

  • Connection settingsthese control which network addresses are allowed to reach the server. If Valkey only serves apps on the same machine, keep it limited to local connections.
  • Password settingsset a password if other machines or users can reach the server, so that not everyone can read or change your data.

Change one setting at a time and note what you changed. That makes it easy to undo a mistake later.

💻Code
......
......
# listening interface
# localhost only by default
# if you'd like to connect from other Hosts,
# change to the own IP address or set to [0.0.0.0]

bind 127.0.0.1 -::1

# By default, outgoing connections (from replica to master, from Sentinel to
# Accept connections on the specified port, default is 6379.
# listening port

port 6379

# By default the server does not run as a daemon. Use 'yes' if you need it.

daemonize yes

# Set the number of databases. The default database is DB 0, you can select
# dbid is a number between 0 and 'databases'-1

databases 16

Once you’re done adjusting the settings, save and exit the file. In nano, press Ctrl+O and then Enter to write the changes, then press Ctrl+X to close the editor. You are back at the terminal prompt. If you want to discard your edits instead, press Ctrl+X and answer N when nano asks to save.

Then, restart Valkey by running the command below. Valkey reads its configuration file only when it starts, so your changes do not take effect until you restart the service. If the command fails, reopen the configuration file and look for a typo in the line you changed. Reverting that line and restarting again will get the server back up.

🐧Bash / Shell
sudo systemctl restart valkey

Operation

To operate Valkey on Ubuntu, use the valkey-cli tool in your terminal to send commands to the server and manage your database. Type valkey-cli and press Enter to connect to your local server, or add connection details if you need to reach a remote database. The sections below cover the most common tasks. Run each command in the block that follows its description.

Advertisement

Connect to the local Valkey server. Run the command in the block below. The prompt changes to show that you are now inside the Valkey console, and anything you type is sent to the server. If you set a password earlier, the server may ask you to authenticate before it accepts other commands.

💻Code
 valkey-cli

Connect to another Valkey server. Use the command below when the database runs on a different machine. Replace the example connection details with the address and port of your own server. The remote server must allow connections from your machine, so check its connection and firewall settings if the attempt fails.

💻Code
valkey-cli -h node01.example.com

Show connected clients. From the Valkey console, run the command below to see which clients are currently attached to the server. This helps you confirm that your applications are really reaching the database.

💻Code
client list

Show stats and requests. Run the command below in the Valkey console to view server statistics, including how many requests it has handled. Check it from time to time to see how busy the server is.

💻Code
info
monitor

Exit from the console. Run the command below when you are finished. You return to the normal terminal prompt, and the Valkey server keeps running in the background.

💻Code
quit

That should do it! Valkey is now installed, configured, and ready for your applications.

Conclusion:

In summary, installing and configuring Valkey on Ubuntu 24.04 is straightforward. Following the abovementioned steps, you can quickly start with the in-memory key-value store. Here are the key takeaways:

  • Ease of InstallationValkey is readily available in Ubuntu’s default repositories, simplifying the installation process.
  • Configuration FlexibilityThe configuration file allows customization to fit various environments and use cases. Remember to restart the service after each change.
  • Basic CommandsFamiliarizing yourself with basic commands ensures Valkey’s efficient operation.
  • Daemon SupportValkey can run as a daemon or in a cluster, offering versatility for different deployment scenarios.
  • Data ManagementSupports a wide range of data types, making it suitable for diverse applications.

Valkey offers an efficient key-value store for anyone needing to manage data quickly. This option is powerful because Valkey version 7.2.5 provides fast data retrieval and storage, making it ideal for applications that require high performance.

Have a question about this guide?

Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.

Did this guide fix your problem?

Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *