[英]Laravel : Redis No connection could be made : [tcp://127.0.0.1:6379]
I have installed redis with laravel by adding "predis/predis":"~1.0"
,我通过添加
"predis/predis":"~1.0"
predis "predis/predis":"~1.0"
predis "predis/predis":"~1.0"
安装了带有 laravel 的 redis,
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 :在 app/config/database.php 我有:
'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]
它抛出以下错误:
No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]
No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]
I using virtualhost
for the project.我为项目使用
virtualhost
。 Using Xampp with windows
.将
Xampp with windows
使用。
First make sure Redis is actually listening on that port by opening up powershell and typing netstat -aon | more
首先确保Redis实际上是通过打开powershell并输入
netstat -aon | more
来侦听该端口 netstat -aon | more
(this command may need to be enabled in features or installed somehow). netstat -aon | more
(此命令可能需要在功能中启用或以某种方式安装)。 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.
如果没有监听,请确保Redis已启动并配置为侦听该端口。
It looks like predis/predis
is a client library only. 看起来
predis/predis
只是一个客户端库。 See https://packagist.org/packages/predis/predis . 请参阅https://packagist.org/packages/predis/predis 。
You need to install the Redis server, but it looks like it is not officially supported on Windows. 您需要安装Redis服务器,但看起来它在Windows上不受官方支持。 See http://redis.io/download .
见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 .
根据该页面上的信息,看起来Redis的Win64端口位于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 参考解决方案: 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.
您需要提供redis服务器的IP。
$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 所以你需要编辑:$ 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 并找到行绑定127.0.0.1 :: 1并将其更改为#bind 127.0.0.1 :: 1然后找到行protected-mode yes然后将其更改为protected-mode no
and then restart the redis server 然后重新启动redis服务器
I had this issue in Ubuntu 18.04 我在Ubuntu 18.04中遇到过这个问题
I installed redis in my local system, got solved. 我在我的本地系统中安装了redis,得到了解决。
sudo apt-get install redis-server
如果您使用的是 Redis,请确保Redis 服务器正在运行,默认情况下在此 6379 端口上
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.