Laravel:Redis无法建立连接:[tcp://127.0.0.1:6379] [英] Laravel : Redis No connection could be made : [tcp://127.0.0.1:6379]

查看:708
本文介绍了Laravel:Redis无法建立连接:[tcp://127.0.0.1:6379]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过添加"predis/predis":"~1.0"和laravel安装了redis,

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);
   } 

在app/config/database.php中,我有:

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,
        ],

    ],

它引发以下错误:No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]

我在项目中使用virtualhost. 使用Xampp with windows.

I using virtualhost for the project. Using Xampp with windows.

推荐答案

首先,通过打开powershell并键入netstat -aon | more,确保Redis实际上在该端口上进行侦听(此命令可能需要在功能中启用或以某种方式安装) .如果正在侦听,请检查防火墙设置.如果不监听,请确保Redis已启动并且已配置为在该端口上监听.

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.

看起来predis/predis只是一个客户端库.参见 https://packagist.org/packages/predis/predis .

It looks like predis/predis is a client library only. See https://packagist.org/packages/predis/predis.

您需要安装Redis服务器,但是Windows似乎不正式支持它.请参阅 http://redis.io/download .根据该页面上的信息,似乎在 https://github.com/MSOpenTech/Redis .

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.

这篇关于Laravel:Redis无法建立连接:[tcp://127.0.0.1:6379]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆