SKDBLOG

DevOps

Install Redis on Ubuntu Server: Official APT Repo & Remote Access

Add packages.redis.io on Ubuntu Server, install Redis through apt, enable redis-server with systemd, then tune redis.conf for LAN-friendly listeners with AUTH—same apt rhythm I reuse beside nginx installs on shared VPS builds.

Shashikant Dwivedi
5 min read
Install Redis on Ubuntu Server: Official APT Repo & Remote Access
DevOps05 MIN

Redis stays fast because it keeps hot data in memory—great when you want cache layers or quick auxiliary storage beside Postgres or MongoDB. If you are standing up another data tier on Ubuntu Server, the predictable path is Redis upstream packages over stale universe snapshots, then systemd for redis-server, then networking knobs only after you mean it—much like the rhythm in MongoDB 7 on Ubuntu.

Security: exposing database ports

Opening database ports to the public internet is convenient for demos and risky in production. Prefer VPN, SSH tunnels, or IP allow lists, enforce TLS where available, and pair strong passwords with firewall rules you actually audit.

Prerequisites

You need a reachable Ubuntu Server image—nothing exotic beyond sudo access and outbound HTTPS so apt can pull signing keys.

Update Ubuntu packages and install repo tooling

Refresh indexes before you bolt on another apt source—small habit that prevents weird resolver conflicts later.

bash
sudo apt-get update
sudo apt-get upgrade -y

Install the helpers Redis documents for third-party repositories:

bash
sudo apt-get install lsb-release curl gpg

When this box eventually terminates HTTP too, I still paste the nginx plus UFW command slab first so apt and firewall sequencing stays identical across stacks.

Add the official Redis apt repository

Redis publishes .deb builds through packages.redis.io, which generally tracks fresher releases than whatever frozen snapshot shipped with your LTS.

Download and armor the signing key:

bash
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

Keep permissions predictable:

bash
sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg

Point apt at the Redis-maintained source—$(lsb_release -cs) resolves jammy, noble, or whichever codename matches your install:

bash
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

Reload indexes:

bash
sudo apt-get update

Install Redis with apt

bash
sudo apt-get install redis

Confirm binaries landed:

bash
redis-server --version

Start redis-server with systemd

Enable the unit so reboots do not silently strand your apps:

bash
sudo systemctl enable redis-server
sudo systemctl start redis-server
sudo systemctl status redis-server

If systemctl status disagrees, grab logs with journalctl -u redis-server -e --no-pager before tweeting—usually it is a typo in redis.conf from an earlier experiment.

Configure bind, protected-mode, and requirepass

Out of the box Redis listens on 127.0.0.1, which is perfect until another VM needs port 6379. Open the config:

bash
sudo nano /etc/redis/redis.conf

Make three coordinated edits:

  • Change bind 127.0.0.1 (no leading #) to bind 0.0.0.0 so redis-server listens on every interface.
  • Flip protected-mode yes to protected-mode no so remote hosts are not instantly rejected once binding widens.
  • Set requirepass your-strong-password-here—swap in a real secret before anyone routes traffic here.

Save (nano: Ctrl+O, Enter, Ctrl+X), then bounce the service:

bash
sudo systemctl restart redis-server
sudo systemctl status redis-server

Remote MongoDB workflows echo the same lesson about tightening listeners before you celebrate—see enable MongoDB remote connections when you want that parallel checklist.

One-shot bash recap

Notice how the spine stays boring on purpose; paste top to bottom when you already internalized the narration:

bash
# Update system and install prerequisites
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install lsb-release curl gpg

# Add Redis GPG key and repository
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

sudo apt-get update

# Install Redis
sudo apt-get install redis

# Enable and start the service
sudo systemctl enable redis-server
sudo systemctl start redis-server
sudo systemctl status redis-server

Remote checklist:

  1. Edit /etc/redis/redis.conf (sudo nano /etc/redis/redis.conf or your editor).
  2. Set bind 0.0.0.0, protected-mode no, and requirepass <secret>.
  3. Restart redis-server:
bash
sudo systemctl restart redis-server
sudo systemctl status redis-server

Need TLS termination or routing rules in front of apps? Pair this baseline with nginx reverse proxy setup once Redis sits behind something that speaks HTTP for your clients.

Frequently asked questions

Why use packages.redis.io instead of only Ubuntu universe Redis packages?

You get Redis-maintained builds that track upstream fixes faster than frozen distro snapshots, plus apt verification anchored on their signing key—so dependency hygiene stays closer to what Redis documents.

What does switching bind from 127.0.0.1 to 0.0.0.0 accomplish?

It moves redis-server from localhost-only listeners to every interface on the NIC. Remote peers can now reach port 6379 once networks and firewalls allow it.

Why should requirepass appear before you advertise Redis beyond localhost?

Redis commands execute quickly—including destructive ones. AUTH enforcement stops anonymous clients from flipping keys the moment your bind statement widens.

No—keep Redis on private networks when you can. SSH tunnels, VPNs, or tight allow lists beat exposing raw 6379 because passwords alone are never the entire story.

Which systemd unit should I restart after editing redis.conf?

Ubuntu packages hook redis-server.service, so prefer sudo systemctl restart redis-server followed by status checks rather than guessing legacy aliases.

You now have Redis installed from the official apt repository, wired through systemd, and configured for authenticated remote clients—without losing the cautious posture this workload deserves. If something still misbehaves, drop the systemctl status snippet or journalctl excerpt and we can trace it together.

Written by Shashikant Dwivedi

Engineer, occasional writer, full-time noticer. Based in Prayagraj, India. New essays land roughly twice a month.

Keep reading

Adjacent essays.

All writing →

The newsletter

New articles in your inbox.

Occasional articles on engineering, tooling, and software development practices. No marketing, no fluff — just the article, when it's ready.

Unsubscribe with one click. Your email never leaves the list.