I have installed redis with laravel by adding "predis/predis":"~1.0"
,
Then for testing i added the following code :
public function showRedis($id = 1)
{
$user = Redis::get('user:profile:'.$id);
Xdd($user);
}
In app/config/database.php i have :
'redis' => [
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
It throws the following error : No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]
I using virtualhost
for the project.
Using Xampp with windows
.
I had this issue in Ubuntu 18.04
I installed redis in my local system, got solved.
sudo apt-get install redis-server
First make sure Redis is actually listening on that port by opening up powershell and typing netstat -aon | more
(this command may need to be enabled in features or installed somehow). If it is listening then check your firewall settings. If if not listening then make sure Redis is started and is configured to listen on that port.
It looks like predis/predis
is a client library only. See https://packagist.org/packages/predis/predis.
You need to install the Redis server, but it looks like it is not officially supported on Windows. See http://redis.io/download. Per information on that page, it looks like there is a Win64 port for Redis here https://github.com/MSOpenTech/redis.
If it still doesn't work after that then update your question with the new error you see.
Ref solution: https://rapidsol.blogspot.com/2018/10/php-fatal-error-uncaught.html
It is showing your server is not accepting connections from outside. You need to provide ip of your redis server.
$client = new Predis\Client('tcp://192.168.1.103:6379');
//$client = new Predis\Client();
$client->set('foo', 'bar');
$value = $client->get('foo');
echo $value; exit;
if problem still come then try below steps.
So you need to edit : $sudo vi /usr/local/etc/redis.conf
and find the line bind 127.0.0.1 ::1 and change it to #bind 127.0.0.1 ::1 and then find line protected-mode yes and then change it to protected-mode no
and then restart the redis server
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With