How to Install and Use Valkey on Ubuntu 26.04 and 24.04

Share

To install Valkey on Ubuntu 26.04 or 24.04, use APT: sudo apt update && sudo apt install valkey. Ubuntu 26.04 supplies Valkey 9.0.x from main; Ubuntu 24.04 supplies 7.2.x from universe. Valkey stores key-value data in memory for tasks such as application caching, counters and queues.

Start with a local service, try a few commands, then configure authentication, persistence and memory limits. Valkey uses port 6379 and works with standard Redis client libraries for compatible commands. If a step fails, leave a comment with the error or contact us.

Before you begin
  • Use Ubuntu 26.04 LTS or 24.04 LTS Desktop or Server, a terminal, internet access and an account with sudo access.
  • These instructions use the Ubuntu APT packages and systemd. Containers and WSL sessions without systemd need a different service workflow.
  • Keep the service local to this computer. You do not need to open port 6379 in your firewall.
  • If Redis or Valkey is already in use, identify it and back up its data before changing services. Installing packages can start a service automatically.

1. Install Valkey with APT

Step 1: Check Ubuntu and port 6379

Check the release and look for an existing listener before installing:

Ubuntu terminal
cat /etc/os-release
sudo ss -tulpn | grep 6379

No grep output means no matching listener was shown. If Redis, Valkey or a container already uses this port, follow the port-conflict section before proceeding. Do not stop an existing database without checking which applications depend on it.

Step 2: Enable universe if needed on Ubuntu 24.04

On a minimal 24.04 system where universe is disabled, enable it first. Skip this block when universe is already enabled, and on 26.04:

Ubuntu terminal
sudo apt update && sudo apt install software-properties-common
sudo add-apt-repository universe

software-properties-common supplies add-apt-repository. Keep the normal updates and security repositories enabled as well; the next step refreshes the package lists.

Step 3: Install the server and client tools

Run this on either supported Ubuntu release:

Ubuntu terminal
sudo apt update && sudo apt install valkey

The && runs installation only after apt update succeeds. valkey is a virtual package provided by valkey-server; the server depends on valkey-tools, which includes valkey-cli. Review APT’s proposed changes before accepting.

Step 4: Verify the installed and candidate versions

Check both the available package and the installed executable:

Ubuntu terminal
apt policy valkey-server valkey-tools
valkey-server --version
valkey-cli --version

On updated amd64 package records checked on 11 November 2026, Ubuntu 26.04 offers 9.0.4-0ubuntu0.2 in main and Ubuntu 24.04 offers 7.2.13+dfsg1-0ubuntu0.1 in universe. Patch versions can change and differ by architecture or enabled pockets; your apt policy output is the local authority.

See Ubuntu’s 26.04 package record and 24.04 package record for the repository versions. An older major version in an Ubuntu LTS repository is expected; ordinary APT updates do not switch 24.04 to Valkey 9.x.

Need newer 9.x features on Ubuntu 24.04?

Upstream is on Valkey 9.1.x at this review. Its official 9.1 download page lists the valkey/valkey Docker images, including the versioned 9.1.3 tag. A container is a separate installation: the APT service, /etc/valkey/valkey.conf and /var/lib/valkey do not configure or store its data automatically. Choose explicit persistent storage and local-only port publishing before using it for real data.

2. Start Valkey and verify the connection

Step 1: Enable and check the Ubuntu service

Enable startup at boot and start the service now:

Ubuntu terminal
sudo systemctl enable --now valkey-server.service
systemctl is-active valkey-server.service
systemctl status valkey-server.service --no-pager

Expect active and an active (running) status. If it failed, inspect the troubleshooting section rather than launching a second valkey-server process by hand.

Step 2: Ping the local server

For a fresh installation before you add a password:

Ubuntu terminal
valkey-cli -h 127.0.0.1 -p 6379 PING

Expect PONG. A preconfigured server may return NOAUTH, which means authentication is required. Use the masked password prompt shown later. A successful ping alone does not identify the server: Redis can also answer PONG.

Step 3: Confirm which server answered

Read the server identification and current listening addresses:

Ubuntu terminal
valkey-cli INFO server | grep -E '^(server_name|valkey_version|config_file):'
sudo ss -ltnp 'sport = :6379'

Look for valkey_version and the configuration path. In the APT setup, that path is /etc/valkey/valkey.conf. Confirm the listeners are 127.0.0.1 and, when IPv6 is available, ::1. A listener on 0.0.0.0 or [::] accepts connections beyond loopback and needs attention before continuing.

3. Store, read and expire a key

Step 1: Open the interactive client

Connect from the same computer:

Ubuntu terminal
valkey-cli

Commands in the next block go inside valkey-cli, not into Bash. If the server already requires authentication, open it with valkey-cli --askpass instead.

Step 2: Try a short-lived cache entry

Use this example namespace only if it is unused. SET replaces an existing key with the same name:

Inside valkey-cli
PING
SET ubuntufree:demo:greeting "Hello from Ubuntu" EX 300
GET ubuntufree:demo:greeting
TTL ubuntufree:demo:greeting
DEL ubuntufree:demo:greeting
GET ubuntufree:demo:greeting
QUIT

PING returns PONG. SET returns OK; GET returns the greeting. EX 300 expires the key after 300 seconds. TTL shows the remaining seconds, so the number decreases. DEL removes only this example key; the last GET returns (nil). QUIT returns to your Ubuntu shell.

A key is the name your application uses to find a value. Prefixes such as myapp:cache: help avoid naming collisions. Use expiry for temporary data, and avoid FLUSHALL or FLUSHDB on an instance that contains application data.

4. Use Redis clients and existing scripts

Standard Redis client libraries can connect to Valkey using the same host, port and compatible commands. Configure your application to use 127.0.0.1:6379 when it runs directly on this Ubuntu host. Inside a container, 127.0.0.1 refers to that container, so it does not reach the host service automatically.

Check for existing Redis data before installing the compatibility package

On Ubuntu 24.04, this package includes an automatic migration script. If /var/lib/redis exists, it can stop Valkey, copy Redis configuration and data into Valkey paths, rename /var/lib/redis to /var/lib/redis-old and leave a migration flag that blocks service startup pending review. Do not install it casually on an existing database host. Back up both services and plan migration first, or update the scripts to call valkey-cli directly.

Optional on Ubuntu 24.04: Keep the redis-cli command name

For a fresh host without an existing /var/lib/redis directory, Ubuntu 24.04 provides this optional package:

Ubuntu terminal
sudo apt install valkey-redis-compat
command -v redis-cli
readlink -f "$(command -v redis-cli)"

This package supplies compatibility symlinks, including redis-cli pointing to valkey-cli. Review APT’s proposed changes before accepting. It is listed for 24.04, but not 26.04 in the checked Ubuntu package records; on 26.04, update your scripts to call valkey-cli instead.

The Ubuntu compatibility package does not prove that an application migration is safe. Valkey preserves Redis OSS 7.2 compatibility; do not assume every newer Redis feature, module or data file works unchanged. For an existing database, follow the official migration guide and test a backup before switching.

5. Configure local access and a password

Step 1: Back up and inspect the configuration

Before editing, preserve the current file and inspect relevant active settings:

Ubuntu terminal
sudo cp --preserve=all --backup=numbered /etc/valkey/valkey.conf /etc/valkey/valkey.conf.before-guide
sudo grep -nE '^[[:space:]]*(include|bind|port|protected-mode|save|appendonly|appendfsync|maxmemory|maxmemory-policy|dir|dbfilename|appenddirname)[[:space:]]' /etc/valkey/valkey.conf
sudoedit /etc/valkey/valkey.conf

The backup command keeps earlier backup files as numbered versions if you repeat it. Keep backups private because configuration can contain passwords. If you find active include directives, read those files and any nested includes too: later settings may override earlier ones. Edit the existing settings rather than appending conflicting copies.

Step 2: Keep loopback binding and add requirepass

In /etc/valkey/valkey.conf, verify these local-only settings. Replace the password placeholder with a long, unique password before saving:

Configuration file
bind 127.0.0.1 -::1
protected-mode yes
port 6379
requirepass "REPLACE_WITH_A_LONG_UNIQUE_PASSWORD"

The minus sign in -::1 allows startup if that IPv6 address is unavailable. requirepass sets authentication for the default user; named ACL users are a more flexible option for multiple applications. Update your application’s connection credentials before the restart. This change disconnects current clients when applied.

Keep the configuration readable only by the administrator and service account. A password does not encrypt TCP traffic, and loopback access is not isolation from every local user or process. Do not replace the bind setting with 0.0.0.0 or open port 6379 to the internet as a connection fix. See Valkey security guidance before planning remote access.

Step 3: Restart and test authentication

On a new instance, apply the change. On an existing instance, check persistence and backups first, and schedule the connection interruption:

Ubuntu terminal
sudo systemctl restart valkey-server.service
systemctl is-active valkey-server.service
valkey-cli PING
valkey-cli --askpass PING

Without credentials, PING should return NOAUTH Authentication required. The --askpass option prompts for the password without displaying it and should return PONG. Avoid putting a password after -a or typing AUTH with a real secret into an interactive history. Use --askpass for later CLI commands in this guide.

Step 4: Confirm effective local binding

Check the running settings after authentication:

Ubuntu terminal
valkey-cli --askpass CONFIG GET bind
sudo ss -ltnp 'sport = :6379'

Confirm loopback addresses only. The CLI documentation explains the password prompt and connection options. If the restart fails, read the service journal and configuration error before retrying.

6. Understand persistence before storing important data

Valkey keeps its working dataset in RAM. Persistence writes recoverable data to disk; it does not replace an independent backup. RDB creates point-in-time snapshots. AOF logs writes and replays them at startup. Expired or evicted keys remain expired or evicted even when persistence is enabled.

Step 1: Inspect the effective persistence settings

From your Ubuntu shell, authenticate for each command:

Ubuntu terminal
valkey-cli --askpass CONFIG GET save
valkey-cli --askpass CONFIG GET appendonly
valkey-cli --askpass CONFIG GET appendfsync
valkey-cli --askpass CONFIG GET dir
valkey-cli --askpass INFO persistence

Ubuntu’s packaged configuration uses /var/lib/valkey for the data directory unless changed. Check actual output rather than assuming a schedule. An empty save value disables scheduled RDB snapshots; appendonly no means AOF is off. INFO persistence includes background-save and AOF status fields.

Choose a policy before a new instance receives real data

For a fresh instance that needs AOF, edit the existing appendonly and appendfsync settings in /etc/valkey/valkey.conf:

Configuration file
appendonly yes
appendfsync everysec

Retain a suitable RDB snapshot schedule if you also want periodic snapshots. Apply changes with a service restart, then check CONFIG GET appendonly and INFO persistence again. With everysec, a crash can typically lose about a second of recent writes; storage failures can have wider effects. Plan disk space and test recovery.

For an existing populated instance, do not enable AOF only by editing the file and restarting. Follow the live-switch procedure in Valkey’s persistence documentation so the existing in-memory dataset is written into AOF first. Changing persistence or restarting without a recoverable dataset can lose data.

7. Set a memory limit for cache workloads

Optional: Allow a disposable cache to evict old keys

For a cache whose entries can all be rebuilt, edit the existing settings in /etc/valkey/valkey.conf. This 256 MB example is a starting point, not a universal recommendation:

Configuration file
maxmemory 256mb
maxmemory-policy allkeys-lru

allkeys-lru can remove any key, including keys without an expiry, when the configured memory threshold is reached. Do not use it for irreplaceable records, queues or sessions you cannot afford to lose. Choose a limit that leaves RAM for Ubuntu, other applications, buffers and persistence work; maxmemory is not a hard limit on the process’s total RAM.

Verify the cache settings

After a planned service restart, confirm the running values:

Ubuntu terminal
sudo systemctl restart valkey-server.service
valkey-cli --askpass CONFIG GET maxmemory
valkey-cli --askpass CONFIG GET maxmemory-policy
valkey-cli --askpass INFO memory

With noeviction, writes that need more memory can fail once the limit is reached instead of evicting keys. The key-eviction guide explains policy choices. Keep cache data in a separate instance when other data needs different retention rules.

8. Fix common installation and startup problems

Issue 1: Valkey fails because port 6379 is occupied

An old redis-server instance is a common conflict. Inspect the listener and service logs:

Ubuntu terminal
sudo ss -tulpn | grep 6379
systemctl status redis-server.service valkey-server.service --no-pager
sudo journalctl -u valkey-server.service -b -n 60 --no-pager

Look for Address already in use and identify the process. Do not kill it or disable Redis blindly. If it is an unused test instance and stopping it is safe, stop that service, then start Valkey. For two services that must coexist, give them different ports and separate data files/directories, and update each client’s connection settings.

Issue 2: APT cannot locate valkey

On 24.04, enable universe as shown above and refresh package lists. Check what APT can see:

Ubuntu terminal
sudo apt update
apt policy valkey-server

Resolve repository or network errors first. Do not mix packages from Ubuntu 26.04 into 24.04 to get a higher version. On 26.04, the Valkey server is in main.

Issue 3: Connection refused, NOAUTH or WRONGPASS

For connection refused, check whether the service is active and inspect its log. For authentication errors, retry with the configured password:

Ubuntu terminal
systemctl status valkey-server.service --no-pager
sudo journalctl -u valkey-server.service -b -n 60 --no-pager
valkey-cli --askpass PING

NOAUTH means credentials are missing; WRONGPASS means the supplied credentials were rejected. A custom port requires the same -p value in the client. Do not remove authentication or widen network access to fix a wrong password.

Issue 4: The service stopped working after a configuration edit

Read the exact error and the packaged log file if the journal does not show the cause:

Ubuntu terminal
sudo journalctl -u valkey-server.service -b -n 60 --no-pager
sudo tail -n 60 /var/log/valkey/valkey-server.log

Check misspelled directives, quoting, duplicate settings and included files. To undo only this guide’s configuration edits, inspect the before-guide backup first. Restoring it restores its earlier authentication and persistence settings too; confirm those are appropriate for the current data before restarting.

Restore the checked configuration backup

Use this only after confirming that /etc/valkey/valkey.conf.before-guide is the version you want. It replaces the current configuration and interrupts clients:

Ubuntu terminal
sudo cp --preserve=all /etc/valkey/valkey.conf.before-guide /etc/valkey/valkey.conf
sudo systemctl restart valkey-server.service
systemctl status valkey-server.service --no-pager

Then repeat the connection test using the restored authentication settings. This restores configuration, not deleted or lost database records.

9. Update or remove Valkey

Update the APT packages

Plan for a possible service restart and back up important data before upgrading:

Ubuntu terminal
sudo apt update && sudo apt install --only-upgrade valkey-server valkey-tools

If you installed the optional 24.04 compatibility package, upgrade it with sudo apt install --only-upgrade valkey-redis-compat too. Check the service and authenticated PING afterward. APT follows your Ubuntu release’s repository series.

Remove the server and client tools

Removal stops applications that depend on this service. Preserve a recoverable database backup and configuration before proceeding:

Ubuntu terminal
sudo systemctl disable --now valkey-server.service
sudo apt remove valkey-server valkey-tools

Review any related packages APT proposes to remove. If valkey-redis-compat was installed, remove it too with sudo apt remove valkey-redis-compat. Package removal is not a database backup. Keep /var/lib/valkey and your configuration backups until recovery has been verified; do not delete the data directory as routine cleanup.

Helpful resources

Official Valkey documentation

Installation and package options covers supported installation routes. Use the security, persistence and eviction guides linked above when moving beyond a local test service.

Frequently asked questions

Does installing valkey include the command-line client?

Yes. In Ubuntu, valkey is a virtual package provided by valkey-server. The server depends on valkey-tools, which includes valkey-cli.

Can my Redis client library connect to Valkey?

Standard Redis clients can connect using the compatible protocol and commands. Check application-specific features and modules before migration; compatibility does not guarantee that newer Redis data files or features work unchanged.

Where is the Valkey configuration file on Ubuntu?

The APT service uses /etc/valkey/valkey.conf and valkey-server.service. Inspect active include directives as well, because included configuration can change the effective settings.

How do I test Valkey after setting a password?

Run valkey-cli --askpass PING and enter the configured password at the masked prompt. A successful authenticated connection returns PONG. Do not place the real password in a command-line argument.

Why will Valkey not start when Redis is already running?

Both commonly use port 6379. Check sudo ss -tulpn | grep 6379 and the Valkey service journal. Identify dependent applications before stopping a service, or configure separate ports and storage if both must run.

Does maxmemory-policy allkeys-lru keep permanent keys safe?

No. It can evict any key, including keys without expiry. Use it only for data that can be rebuilt, and keep data with different retention requirements in a separate instance.

Related Ubuntu guides: Install Docker for container workloads · Check your Ubuntu release · Learn useful Linux commands.