As more users rely on Odoo and the application runs on several servers, in multiple containers, or behind a load balancer, the default file-based session storage is no longer enough. Each instance then has its own session directory, so a user may be logged out after being redirected to a different node. The solution is a fast in-memory data store: Redis. In this guide, we show how to install it, secure it, and connect it to Odoo, as well as the limitations of this approach.
If you would like to see how the system works before you start configuring your infrastructure, try Odoo for free.
What is Redis and why use it with Odoo?
Redis is a fast key-value database that stores data in RAM. In Odoo environments, it is most often used to store user sessions. As a result, sessions do not depend on the file system of a single server, which matters for horizontal scaling, clusters, Docker or Kubernetes, and for multiple Odoo instances behind a load balancer.
The benefits of Redis for Odoo include:
- shared sessions across multiple Odoo instances, so users are not logged out when redirected to a different server,
- lower disk load with a large number of concurrent users,
- easier container deployments, where the file system is ephemeral,
- automatic session expiration thanks to the key time-to-live setting.
If Odoo runs on a single server, even with multiple workers, all processes use the same session directory. In that scenario, Redis is usually not needed.
Important: Odoo has no built-in Redis integration
Before you start, you should know that standard Odoo (Community and Enterprise) does not include native Redis support. By default, sessions are stored on disk in the data directory (data_dir). The integration is provided by third-party modules, most commonly session_redis from the odoo-cloud-platform project (Camptocamp). Before deployment, check the repository to see whether the module has a branch compatible with your Odoo version. This applies especially to the newest versions, for which community support is sometimes available with a delay. Also read the current Odoo documentation and the module's README. Keep in mind that on Odoo Online and Odoo.sh you cannot connect your own Redis service or install a module that requires server-level changes, so this guide applies to self-hosted deployments (on-premise or VPS).
In this setup, Redis is used for sessions only. It does not replace the bus or WebSocket service, which in Odoo rely on PostgreSQL (the LISTEN/NOTIFY mechanism), and it does not take over the ORM cache, which runs in the memory of Odoo processes.
Prerequisites
- a server running Linux (e.g. Ubuntu or Debian) and access to an account with sudo privileges,
- a working Odoo installation, preferably in a separate virtual environment – see our guide how to install Odoo in a Python virtual environment,
- access to the odoo.conf configuration file,
- a backup of the database and files – use the guide how to set up automatic backups in Odoo.
Step 1: Install the Redis server
On Ubuntu or Debian, install Redis from the system repositories:
sudo apt update
sudo apt install redis-server -y
sudo systemctl enable --now redis-server
redis-cli pingThe correct response is PONG. It means the server is running.
Securing the Redis configuration
Open the /etc/redis/redis.conf file and set the basic security and memory parameters:
bind 127.0.0.1
protected-mode yes
requirepass TWOJE_SILNE_HASLO
maxmemory 256mb
maxmemory-policy volatile-lruListening only on the local address and using a password protect Redis from unauthorized access. If Redis runs on a separate server, set the appropriate internal address in bind and restrict access with a firewall to the addresses of the Odoo servers. Never expose Redis directly to the internet.
Choose the maxmemory value based on the number of concurrent users. When memory runs out, the volatile-lru policy starts evicting keys that have a TTL set, which includes active sessions and results in users being logged out. Then restart the service:
sudo systemctl restart redis-serverStep 2: Python library for Redis
Odoo communicates with Redis through the redis library. Install it in the same virtual environment in which Odoo runs:
source /opt/odoo/venv/bin/activate
pip install redisStep 3: Install the session_redis module
Download the module from the odoo-cloud-platform repository, choosing the branch that matches your Odoo version, and add its directory to addons_path. The module must be loaded as soon as the server starts, so it is added to server_wide_modules.
Configuration in the odoo.conf file
[options]
server_wide_modules = base,web,session_redis
addons_path = /opt/odoo/addons,/opt/odoo/odoo/addons,/opt/odoo/custom-addons,/opt/odoo/odoo-cloud-platformAdjust the paths to your own installation. In a source installation, the Odoo core is located in the addons and odoo/addons directories.
Environment variables
Connection parameters are passed through environment variables. Because they contain a password, do not place them in plain text in the service file. Save them in a separate file, e.g. /etc/odoo/redis.env, with 600 permissions (owner: the user under which Odoo runs):
ODOO_SESSION_REDIS=1
ODOO_SESSION_REDIS_HOST=127.0.0.1
ODOO_SESSION_REDIS_PORT=6379
ODOO_SESSION_REDIS_PASSWORD=TWOJE_SILNE_HASLO
ODOO_SESSION_REDIS_PREFIX=odoo-prod
ODOO_SESSION_REDIS_EXPIRATION=86400
ODOO_SESSION_REDIS_EXPIRATION_ANONYMOUS=3600Then point to the file in the systemd service (the [Service] section) or in the container configuration:
EnvironmentFile=/etc/odoo/redis.envThe prefix lets you use a single Redis instance for multiple environments. The expiration parameter sets the lifetime, in seconds, of sessions for logged-in users, and expiration_anonymous sets the lifetime of anonymous sessions, e.g. website visitors. After changing the service file, run sudo systemctl daemon-reload.
Infrastructure configuration, module compatibility, and security are areas where mistakes are easy to make. If you would rather leave it to specialists, contact our team.
Step 4: Restart Odoo and verify that it works
Restart the Odoo service and check the logs:
sudo systemctl restart odoo
sudo journalctl -u odoo -fLog in to Odoo in your browser, then check whether session keys have appeared in Redis. Pass the password through an environment variable so it is not left in your command history:
export REDISCLI_AUTH='TWOJE_SILNE_HASLO'
redis-cli --scan --pattern 'odoo-prod*'If you see keys with your prefix, you have successfully configured Redis for Odoo. Additionally, test a scenario with two instances: log in, then restart one of them. The session should remain active.
Best practices
- Do not use the KEYS command in production – use
--scaninstead, which does not block the server. - Monitor memory – watch
redis-cli info memoryand adjustmaxmemoryto the number of users. - Combine with workers – with multiple processes, it is worth reading how to configure Odoo with multiple workers.
- Optimize the whole setup – Redis is just one element of a high-performing environment; you will find more tips in the article how to optimize Odoo performance.
- Ensure availability – for critical deployments, consider replication or Redis Sentinel so that the failure of one node does not log out all users.
- Test after updates – after every Odoo update, check whether the session_redis module has a compatible branch and test logging in on a staging environment.
Want to see how Odoo handles the processes in your company before you invest in infrastructure? Test the system in practice.
Common problems
- Redis connection error – check the host, port, and password, and whether the service is running (
systemctl status redis-server). - No keys in Redis – make sure
session_redisis inserver_wide_modules, thatODOO_SESSION_REDIS=1is set, and that the Odoo service actually reads the environment variables file. - Missing redis library – install it in the same virtual environment that Odoo uses.
- Users being logged out – check the
maxmemory-policysetting and available memory, because running out of memory can evict session keys.
FAQ – frequently asked questions
Does Odoo support Redis by default?
No. Standard Odoo stores sessions on disk. Redis integration is provided by additional modules, such as session_redis, which you have to install and configure yourself.
Can I use Redis with Odoo Online or Odoo.sh?
No, because on these platforms you have no access to the server infrastructure and cannot connect your own Redis service. This solution is intended for self-hosted installations (on-premise or VPS).
Does Redis make Odoo faster?
Redis mainly makes scaling easier and allows sessions to be shared between instances. It offloads the disk, but it does not replace other optimization measures such as workers, PostgreSQL tuning, or adequate server resources.
Will Redis replace PostgreSQL for real-time notifications?
No. The bus and WebSocket services in Odoo rely on PostgreSQL, and in this setup Redis is responsible for sessions only.
Summary
To configure Redis for Odoo, you install the Redis server, secure it with a password, add the Python library, enable the session_redis module, and verify that sessions are being stored. This approach helps you build a scalable and resilient production environment, provided Odoo runs on your own infrastructure and the module is compatible with your version of the system.
Need help with Odoo implementation, migration, or optimization? The KK Innovations team will gladly design and configure an environment tailored to your company. Get in touch and let's discuss your project.