I need help setting up Redis correctly in Laravel. I've already tried what I found on the internet, but I'm not sure if I'm missing a step. I'm getting the following error:
In PhpRedisConnector.php line 161: Connection refused
I installed the Redis extension for PHP, I think i can confirm it with this:
Then I installed Docker and Redis, and I received the PONG from the PING.
Also, I have restarted FPM With
sudo systemctl restart php8.1-fpm.service
After that, I cleared the Laravel cache.
And I configured the .env with the following.
And i try to execute this artisan command and i get the error:
<?phpnamespace App\Console\Commands;use Illuminate\Console\Command;use Illuminate\Support\Facades\Redis;class TestRedisCommand extends Command{ /** * The name and signature of the console command. * * @var string */ protected $signature = 'custom:test_redis'; /** * The console command description. * * @var string */ protected $description = 'Command description'; /** * Execute the console command. * * @return int */ public function handle() { $redis = Redis::connection(); if ($redis->ping()) { echo "Conexión Exitosa"; } return Command::SUCCESS; }}
Please, is there something I'm missing? I don't see where the error could be.