How to Install Redis on Ubuntu 26.04

Redis is a powerful, open-source, in-memory data structure store widely used as a database, cache, message broker, and streaming engine. If you are looking to redis install Ubuntu 26.04, this guide walks you through every step, from installation and security hardening to persistence configuration and basic usage with redis-cli. By the end, you will have a fully functional and secure Redis instance running on your Ubuntu 26.04 Resolute Raccoon system.

In this tutorial you will learn:

  • How to install Redis server from the Ubuntu 26.04 repository
  • How to configure Redis bind address, password, and memory limits
  • How to secure Redis with authentication and firewall rules
  • How to test Redis using the redis-cli command line tool
  • How to enable RDB and AOF persistence for data durability
  • How to manage the Redis service with systemd
Abstract illustration representing Redis in-memory data store on Ubuntu Linux with data structure and caching visual elements
Installing and configuring Redis on Ubuntu 26.04 Resolute Raccoon

Software Requirements

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 26.04 Resolute Raccoon
Software Redis 8.0.5 (from Ubuntu repository)
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user
TL;DR
Install Redis on Ubuntu 26.04 with a few commands and secure it with password authentication.

Quick Steps to Install Redis on Ubuntu 26.04
Step Command/Action
1. Install Redis $ sudo apt install redis-server
2. Set a password Edit /etc/redis/redis.conf and set requirepass LinuxConfig_passwd_2026
3. Restart Redis $ sudo systemctl restart redis-server
4. Test connection $ redis-cli PING

Understanding Redis

Redis (Remote Dictionary Server) is an open-source, in-memory data structure store that operates at extremely high speeds because it keeps all data in RAM. Unlike traditional disk-based databases, Redis can handle millions of requests per second, making it an ideal choice for scenarios where performance is critical.

Common use cases for Redis include:

  • Caching: Store frequently accessed data in memory to reduce database load and speed up application response times.
  • Session management: Maintain user session data for web applications with fast read and write access.
  • Message broker: Use Redis Pub/Sub or Streams for real-time messaging between application components.
  • Rate limiting: Track and limit API requests using Redis counters with automatic expiration.
  • Leaderboards and counters: Leverage sorted sets for real-time rankings and atomic increment operations.

Redis supports a variety of data structures including strings, hashes, lists, sets, sorted sets, bitmaps, and streams. This versatility, combined with its speed, makes it one of the most popular choices for modern application architectures. For a comprehensive overview, consult the official Redis installation documentation.

Installing Redis on Ubuntu 26.04

The redis install Ubuntu 26.04 process is straightforward because the redis-server package is available directly from the default Ubuntu repository. Therefore, there is no need to add third-party sources.

  1. Update your package index: Before installing any new software, refresh the local package cache to ensure you get the latest available version:
    $ sudo apt update
  2. Install the Redis server package: Install Redis along with its command-line client tool:
    $ sudo apt install redis-server

    This installs the redis-server daemon and the redis-cli utility. The installation automatically creates the Redis configuration file at /etc/redis/redis.conf and sets up the systemd service unit.

  3. Verify the Redis version: Confirm the installed version:
    $ redis-server --version

    Terminal output of redis-server --version showing Redis 8.0.5 installed on Ubuntu 26.04
    Verifying the installed Redis server version 8.0.5 on Ubuntu 26.04
  4. Check the service status: Redis should start automatically after installation. Verify it is running:
    $ sudo systemctl status redis-server

    Terminal output of systemctl status redis-server showing active and running Redis service on Ubuntu 26.04
    Confirming the Redis server service is active and running on Ubuntu 26.04

At this point, Redis is installed and running on your Ubuntu 26.04 system with its default configuration. The next step is to adjust the configuration to match your requirements.

Configuring Redis on Ubuntu 26.04

The main Redis configuration file is located at /etc/redis/redis.conf. This section covers the most important settings you should review and adjust after a fresh installation.

  1. Open the configuration file: Use your preferred text editor to modify the Redis configuration:
    $ sudo nano /etc/redis/redis.conf
  2. Configure the bind address: By default, Redis binds to 127.0.0.1 -::1, meaning it only accepts connections from the local machine. If you need Redis to accept connections from specific network interfaces, modify the bind directive. For local-only access (recommended for most setups), keep the default:
    bind 127.0.0.1 -::1

    If you need to allow connections from a specific IP on your network, add it:

    bind 127.0.0.1 192.168.1.100
  3. Set a memory limit: To prevent Redis from consuming all available system memory, set a maximum memory limit using the maxmemory directive. For example, to limit Redis to 256 MB:
    maxmemory 256mb

    Additionally, configure an eviction policy that determines how Redis handles new writes when the memory limit is reached:

    maxmemory-policy allkeys-lru

    The allkeys-lru policy removes the least recently used keys first, which is suitable for most caching use cases.

  4. Save and restart Redis: After making your changes, save the file and restart the Redis service to apply the new configuration:
    $ sudo systemctl restart redis-server

Securing Redis Installation

Redis is designed for use in trusted environments; however, it is essential to apply proper security measures to prevent unauthorized access. This section covers the critical steps to harden your Redis installation on Ubuntu 26.04.

Setting Password Authentication

  1. Open the Redis configuration file:
    $ sudo nano /etc/redis/redis.conf
  2. Set a strong password: Locate the requirepass directive (commented out by default), uncomment it, and set a strong password:
    requirepass LinuxConfig_passwd_2026

    Choose a long, complex password because Redis is extremely fast and can process a large number of password attempts per second.

  3. Restart Redis to apply the change:
    $ sudo systemctl restart redis-server
  4. Verify password authentication is active: Attempt to connect without a password and confirm that Redis rejects unauthenticated commands:
    $ redis-cli PING
    (error) NOAUTH Authentication required.

    Then authenticate and verify access:

    $ redis-cli -a LinuxConfig_passwd_2026 PING
    PONG

    IMPORTANT
    When using the -a flag with redis-cli, you will see a warning: “Using a password with ‘-a’ or ‘-u’ option on the command line interface may not be safe.” This is expected behavior. For interactive sessions, connect with redis-cli first and then use the AUTH command to authenticate.

    Terminal showing Redis password authentication test with NOAUTH error and successful authenticated PING on Ubuntu 26.04
    Testing Redis password authentication by verifying unauthenticated access is denied and authenticated PING returns PONG

Disabling Dangerous Commands

Redis includes commands such as FLUSHALL, FLUSHDB, CONFIG, and KEYS that can be destructive or expose sensitive information. You can rename or disable these commands in /etc/redis/redis.conf:

rename-command FLUSHALL "LINUXCONFIGFLASH"
rename-command FLUSHDB ""
rename-command CONFIG "linuxconfig_config_2025"
Nano editor showing rename-command directives in redis.conf on Ubuntu 26.04 to disable and rename dangerous Redis commands
Editing redis.conf to rename FLUSHALL, disable FLUSHDB, and rename CONFIG commands

Setting a command to an empty string ("") disables it entirely. Alternatively, renaming it to a hard-to-guess string allows restricted access for administrators who know the renamed command. After adding these directives, restart Redis and verify:

$ sudo systemctl restart redis-server
$ redis-cli -a LinuxConfig_passwd_2026 FLUSHDB
(error) ERR unknown command 'FLUSHDB', with args beginning with:

The disabled FLUSHDB command is rejected, while the renamed FLUSHALL remains accessible through its new alias LINUXCONFIGFLASH:

$ redis-cli -a LinuxConfig_passwd_2026 LINUXCONFIGFLASH
OK
Terminal showing disabled FLUSHDB command returning error and renamed FLUSHALL working as LINUXCONFIGFLASH on Ubuntu 26.04
Verifying that FLUSHDB is disabled and FLUSHALL is accessible via its renamed alias LINUXCONFIGFLASH

Configuring Firewall Rules

If your Redis instance needs to accept remote connections, you should restrict access using UFW (Uncomplicated Firewall). For example, to allow connections only from a specific application server at 192.168.1.50:

$ sudo ufw allow from 192.168.1.50 to any port 6379

Moreover, if Redis should only be accessible locally, ensure the bind address is set to 127.0.0.1 and no firewall rule opens port 6379 to external networks. For more details on managing firewall rules, see how to allow ports with UFW on Ubuntu 26.04.

Terminal showing UFW firewall rule allowing Redis port 6379 from IP 192.168.1.50 on Ubuntu 26.04
Adding a UFW rule to allow Redis connections on port 6379 from a specific IP address

SECURITY ALERT
Never expose Redis to the public internet without authentication and firewall restrictions. An unprotected Redis instance can be compromised within minutes by automated scanning tools.

Testing Redis with redis-cli

The redis-cli tool is the standard command-line interface for interacting with a Redis server. Use it to verify that your installation and configuration are working correctly.

  1. Connect to Redis: Launch the Redis CLI:
    $ redis-cli

    If you configured password authentication, you will need to authenticate before running any commands.

  2. Authenticate with your password: Use the AUTH command:
    127.0.0.1:6379> AUTH LinuxConfig_passwd_2026
    OK

    Alternatively, you can pass the password directly when connecting:

    $ redis-cli -a LinuxConfig_passwd_2026
  3. Test the connection with PING: The PING command verifies that the server is responsive:
    127.0.0.1:6379> PING
    PONG

    A PONG response confirms that Redis is running and accepting commands.

  4. Store and retrieve a test value: Use SET and GET to write and read a key-value pair:
    127.0.0.1:6379> SET greeting "Hello from LinuxConfig.org"
    OK
    127.0.0.1:6379> GET greeting
    "Hello from LinuxConfig.org"
  5. Explore additional data types: Redis supports multiple data structures. Here are a few examples:
    127.0.0.1:6379> LPUSH linuxconfig_tasks "Deploy app" "Update docs" "Run tests"
    (integer) 3
    127.0.0.1:6379> LRANGE linuxconfig_tasks 0 -1
    1) "Run tests"
    2) "Update docs"
    3) "Deploy app"
    127.0.0.1:6379> HSET linuxconfig_server hostname "linuxconfig-server" os "Ubuntu 26.04"
    (integer) 2
    127.0.0.1:6379> HGETALL linuxconfig_server
    1) "hostname"
    2) "linuxconfig-server"
    3) "os"
    4) "Ubuntu 26.04"
  6. Check server information: The INFO command provides detailed server statistics:
    127.0.0.1:6379> INFO server

    This outputs version information, uptime, configuration details, and more.

Terminal showing redis-cli session with AUTH, PING, SET, GET, LPUSH, LRANGE, HSET, and HGETALL commands on Ubuntu 26.04
Interactive redis-cli session demonstrating authentication and basic Redis data type operations

COMPLETED
If you received a PONG response and successfully stored and retrieved data, your Redis installation on Ubuntu 26.04 is fully operational.

Enabling Redis Persistence

Since Redis stores data in memory, all data would be lost on a server restart without persistence enabled. Redis offers two persistence mechanisms that can be used independently or together for maximum data durability.

RDB Snapshots (Point-in-Time Snapshots)

RDB persistence creates snapshots of the dataset at specified intervals. This is the default persistence method and is already enabled in a fresh Redis 8.0.5 installation on Ubuntu 26.04. Although the save directives do not appear explicitly in /etc/redis/redis.conf, Redis applies compiled-in defaults that you can verify with:

$ redis-cli CONFIG GET save
1) "save"
2) "3600 1 300 100 60 10000"

These defaults instruct Redis to save a snapshot if at least 1 key changed within 3600 seconds (1 hour), 100 keys changed within 300 seconds (5 minutes), or 10,000 keys changed within 60 seconds. You can override these values by adding explicit save directives to /etc/redis/redis.conf. The snapshot file is stored at the path defined by the dbfilename and dir directives:

dbfilename dump.rdb
dir /var/lib/redis

AOF (Append Only File)

AOF persistence logs every write operation received by the server, providing a more durable (but slightly slower) persistence mechanism. To enable AOF, edit /etc/redis/redis.conf:

appendonly yes
appendfilename "appendonly.aof"

Additionally, configure the fsync policy to control how often data is flushed to disk:

appendfsync everysec

The everysec option offers a good balance between performance and durability by flushing data to disk once every second. Other options include always (safest, slowest) and no (fastest, relies on OS).

After making changes, restart Redis:

$ sudo systemctl restart redis-server

[IMAGE PLACEHOLDER: Terminal showing Redis persistence configuration in redis.conf]

IMPORTANT
For production environments, enabling both RDB and AOF persistence provides the best combination of fast recovery (RDB) and minimal data loss (AOF). Redis will use the AOF file for recovery on startup when both are enabled, as it is typically more complete.

Managing Redis with systemd

Redis on Ubuntu 26.04 runs as a systemd service, which provides convenient commands for managing the server lifecycle. Here are the essential service management commands:

  1. Check service status:
    $ sudo systemctl status redis-server
  2. Stop Redis:
    $ sudo systemctl stop redis-server
  3. Start Redis:
    $ sudo systemctl start redis-server
  4. Restart Redis (apply configuration changes):
    $ sudo systemctl restart redis-server
  5. Enable Redis to start on boot (enabled by default after installation):
    $ sudo systemctl enable redis-server
  6. Disable Redis from starting on boot:
    $ sudo systemctl disable redis-server
  7. View Redis logs: Use journalctl to inspect Redis log output:
    $ sudo journalctl -u redis-server -f

    The -f flag follows the log in real time, which is useful for monitoring and troubleshooting.

[IMAGE PLACEHOLDER: Terminal showing systemctl commands for Redis service management]

Conclusion

You have successfully completed the Redis install on Ubuntu 26.04 Resolute Raccoon. Throughout this guide, you installed the Redis server from the Ubuntu repository, configured essential settings including bind address and memory limits, secured the installation with password authentication and firewall rules, tested the server with redis-cli, and enabled persistence to protect your data. Redis is now ready to serve as a high-performance cache, session store, or message broker for your applications.

Frequently Asked Questions

  1. What is the default port for Redis on Ubuntu 26.04? Redis listens on port 6379 by default. You can change this by modifying the port directive in /etc/redis/redis.conf and restarting the service.
  2. How do I check if Redis is running on Ubuntu 26.04? Run sudo systemctl status redis-server to see whether the service is active. Alternatively, execute redis-cli PING and expect a PONG response to confirm the server is responsive.
  3. Can I use Redis alongside MySQL or PostgreSQL? Yes. Redis is commonly used as a complementary caching layer in front of relational databases. Your application reads frequently accessed data from Redis (fast, in-memory) and falls back to the relational database for cache misses, significantly reducing database load.
  4. How do I completely uninstall Redis from Ubuntu 26.04? Run sudo apt purge redis-server redis-tools to remove the packages and their configuration files. Additionally, delete the data directory with sudo rm -rf /var/lib/redis if you want to remove all stored data.
  5. Should I use RDB or AOF persistence? For most production environments, enabling both is recommended. RDB provides fast restarts with periodic snapshots, while AOF minimizes data loss by logging every write operation. When both are enabled, Redis uses the AOF file for recovery because it is typically more complete.