Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124

If you’re a Laravel developer, encountering the “Laravel Redis connection [cache] not configured” error can be frustrating. Redis has become a vital component for caching, session management, and queue handling in modern Laravel applications. Proper configuration ensures your app runs smoothly and leverages Redis’s speed and scalability. This comprehensive guide explains everything you need to know to troubleshoot and resolve this error efficiently, whether you’re just setting up Redis or troubleshooting a misconfiguration.
Laravel offers a robust caching system that helps improve application performance by temporarily storing data. Instead of fetching information repeatedly from the database, Laravel stores it in cache, reducing latency and server load. Caching is essential for scaling applications and providing a smoother user experience.
Laravel supports several cache drivers, each suitable for different scenarios:
Redis is an in-memory data store, making it incredibly fast. This speed is essential for handling high traffic, sessions, and real-time features efficiently.
Redis supports lists, sets, hashes, sorted sets, and more, allowing you to build complex caching mechanisms and real-time data solutions.
Redis can be scaled horizontally via clustering, making it suitable for large applications needing high availability and load balancing. Many enterprises rely on Redis for caching, session storage, and message queuing.
This error indicates that Laravel is unable to connect to your Redis server because of misconfiguration. It appears when Laravel’s cache system attempts to use Redis but cannot establish a connection.
config/database.php or config/cache.php.env are not properly setThe main consequence is that caching, sessions, or queues that depend on Redis will not work. Your app may experience slower response times, failed login sessions, or errors preventing smooth functionality.
systemctl start redis or service redis startredis-cli pingIf Redis responds with PONG, it’s running correctly. Otherwise, troubleshoot your server setup.
The main configuration files are config/database.php and config/cache.php. Laravel reads Redis connection settings from these files, especially the redis connection block.
'redis' => [
'client' => 'phpredis', // or 'predis'
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
Properly set the Redis parameters:
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=null # or your password
Once updated, run php artisan config:cache to ensure Laravel uses latest environment variables.
CACHE_DRIVER=redis
'redis'php -m | grep redissudo apt-get install php-redis # for Debian/Ubuntu
php-fpm or apache2)| Cause | Description | Solution |
|---|---|---|
| Missing or incorrect .env variables | Environment variables not set or wrong values | Update .env with correct Redis parameters and run php artisan config:cache |
| Redis server not running | Redis service is not active or crashed | Start Redis and verify status using redis-cli ping |
| Improper configuration in config files | Wrong settings in config/database.php or config/cache.php |
Ensure correct syntax and environment variables usage |
| PHP Redis extension missing | The PHP extension php-redis not installed/enabled | Install extension and restart PHP |
| Network/firewall issues | Blocked Redis port (default 6379) | Allow access through firewall rules or network configuration |
config/database.phpredis as shown in config/cache.phpphp artisan cache:clear to clear cachephp artisan config:clear when changing config filesphp artisan config:cacheEnhance robustness by catching Redis connection errors and logging them for future troubleshooting. Laravel’s logging system can capture such errors, enabling proactive issue resolution.
Use redis-cli ping from your server terminal. If you get PONG, Redis is reachable.
For large-scale applications, Consider Redis clustering or replication for high availability. Resources like Redis Cluster Setup can guide you.
Tools like Redis Monitor, RedisInsight, and logs help track Redis health and optimize performance.
Below is a quick reference table encapsulating the primary steps to fix and prevent the “laravel redis connection [cache] not configured” error:
| Step | Check / Action | Expected Outcome |
|---|---|---|
| 1 | Verify Redis service is running with redis-cli ping |
Response: PONG |
| 2 | Confirm environment variables in .env |
Proper Redis host, port, and password are set |
| 3 | Check configuration files for correct Redis connection block | Parameters correctly reference environment variables |
| 4 | Ensure PHP Redis extension is installed and enabled | phpinfo() shows Redis enabled; php -m lists redis |
| 5 | Set CACHE_DRIVER=redis in .env |
Cache driver uses Redis as intended |
.env (set to redis) and confirm Redis-related configurations are present.REDIS_HOST in .env with the remote server’s IP or hostname. Ensure network/firewall rules permit access.config/cache.php.redis-cli monitor or monitoring dashboards such as RedisInsight.Addressing the “Laravel Redis connection [cache] not configured” error primarily involves verifying your Redis server status, ensuring correct configuration in Laravel’s files, setting appropriate environment variables, and confirming the PHP Redis extension is active. Following this comprehensive guide, you can troubleshoot common issues swiftly, securing a stable and high-performance caching layer for your Laravel application. Proper configuration not only resolves immediate errors but also lays the foundation for scalable, reliable application architecture.