My project will not start without Redis running. I get this message if I try to open a page without redis running in Laravel:
“No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]”
I’ve tried
1) php artisan config:cache,
2) php artisan clear:cache,
3) composer remove predis/predis
4) composer remove predis
5) removing instances of redis
6) uninstall redis through command line
Any help would be greatly appreciated! Thanks!
cache.php
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis"
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'file',
'connection' => 'default',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => env(
'CACHE_PREFIX',
str_slug(env('APP_NAME', 'laravel'), '_').'_cache'
),
];
.env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:duZtCSIh12vDNOdmYW2kmMr9ONILxsH55f46npt5/Kg=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forum
DB_USERNAME=
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=bc05914be7f1db
MAIL_PASSWORD=0c73506a138d3f
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
RECAPTCHA_SECRET=
2
Answers
If you don’t want to install any cache service like Redis or Memcached, you can use the
file
ordatabase
driver on Laravel.To change the cache driver you must change the
CACHE_DRIVER
variable your.env
file tofile
, or modify theconfig/cache.php
file.The default cache.php config file looks like this:
The
env()
function get the data from environment variable defined on first parameter, and fallback to the value defined on second parameter. So if your .env file define a CACHE_DRIVER variable, it will ignore the second parameter value.For more information, see https://laravel.com/docs/5.8/cache
I got the same issue just now. The error:
This means there is something in the app that still use redis for its service.
No need to comment or remove Redis in config/app.php
If you are planning of simply switching out redis for later, no need to remove
use Redis;
in the files that will need it in the future. On production better remove these completely.Same with
phpredis
orpredis
, no need to remove them if you will use it for later otherwise.Key here is to check all your config to better have idea where whose redis things are or simply by using your text editor, just search all through the files with redis keyword.