OKAll services are operational
InfrawireInfrawire LogoDocumentation

Install Redis on a Linux VPS

Redis is an in-memory key-value store, widely used for caching, web sessions, queues (with appropriate libraries), and rate limiting. This guide installs Redis on Ubuntu/Debian with a local-only default (recommended).

Prerequisites

  • VPS with sudo
  • Ubuntu 20.04+ or Debian 11+

Installation

Bash
1sudo apt update && sudo apt upgrade -y 2sudo apt install -y redis-server 3sudo systemctl enable redis-server 4sudo systemctl start redis-server 5sudo systemctl status redis-server

Quick test

Bash
redis-cli ping

Expected: PONG.

Bash
redis-cli SET test "hello" redis-cli GET test

Main configuration file

On Debian/Ubuntu, configuration is often /etc/redis/redis.conf.

Important settings:

  • bind: often 127.0.0.1 ::1 — keep localhost only if the app runs on the same server.
  • protected-mode yes: keep enabled unless you have proper authentication and exposure rules.
  • supervised systemd: good integration with systemd (depending on package version).

After edits:

Bash
sudo systemctl restart redis-server

In redis.conf:

Config
requirepass your_long_password

Connect:

Bash
redis-cli -a 'your_long_password' ping

Never commit passwords to Git; use environment variables.

Memory and persistence

  • maxmemory: cap RAM on small VPS (e.g. maxmemory 256mb with maxmemory-policy allkeys-lru for cache-only use).
  • RDB/AOF: Redis can persist to disk; pure volatile cache setups may reduce persistence (understand data-loss risk).

Security

  • Do not expose Redis to the internet without tunnel, VPN, or very strict firewall rules.
  • Combine with UFW for other public ports.

Application connection string

Local typical URL:

TEXT
redis://127.0.0.1:6379

With password:

TEXT
redis://:[email protected]:6379

Troubleshooting

  • Connection refused: service stopped or wrong port; check sudo systemctl status redis-server and ss -tlnp | grep 6379.
  • OOM: lower maxmemory or add RAM.