简体   繁体   English

连接被拒绝 [tcp://127.0.0.1:6379] Laravel Predis

[英]Connection refused [tcp://127.0.0.1:6379] Laravel Predis

I'm trying to setup Redis client to connect to the Redis server in Laravel 6.0 version, but when I try to change the REDIS_HOST in database.php file in config it gives me an error: I'm trying to setup Redis client to connect to the Redis server in Laravel 6.0 version, but when I try to change the REDIS_HOST in database.php file in config it gives me an error:

Connection refused 127.0.0.1:6379连接被拒绝 127.0.0.1:6379

This is how my code looks like in routes api.php file这就是我的代码在路线api.php文件中的样子

Route::get('test',function(Request $request){

  $redis=Redis::connection();
  $redis->set("key1","keyValue");
  $a=$redis->get("key1");
  return response()->json( ['test'=>$a,]);
});

and this is how my database.php file looks like这就是我的database.php文件的样子

      'redis' => [

            'client' => env('REDIS_CLIENT', 'predis'),

            'options' => [
                'cluster' => env('REDIS_CLUSTER', 'redis'),
                'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
            ],

            'default' => [
                'url' => env('REDIS_URL'),
                'host' => env('REDIS_HOST', '127.0.0.1'),
                'password' => env('REDIS_PASSWORD', null),
                'port' => env('REDIS_PORT', 6379),
                'database' => env('REDIS_DB', 0),
            ],

            'cache' => [
                'url' => env('REDIS_URL'),
                'host' => env('REDIS_HOST', '127.0.0.1'),
                'password' => env('REDIS_PASSWORD', null),
                'port' => env('REDIS_PORT', 6379),
                'database' => env('REDIS_CACHE_DB', 1),
            ],
        ],

So when i change the REDIS_HOST its gives me error,any idea is my code problem the configurations?因此,当我更改 REDIS_HOST 时,它给了我错误,知道我的代码问题是配置吗?

Thanks !谢谢 !

I encountered this on my MacBook and fixed it by installing Redis using homebrew as directed here我在我的 MacBook 上遇到了这个问题,并按照此处的指示使用自制软件安装 Redis 来修复它

PS: I'm working with Laravel 8.40 PS:我正在使用 Laravel 8.40

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel:Redis 无法建立连接:[tcp://127.0.0.1:6379] - Laravel : Redis No connection could be made : [tcp://127.0.0.1:6379] 连接被拒绝[tcp:// IP-ADDRESS-HERE:6379] Redis。 Laravel - Connection refused [tcp://IP-ADDRESS-HERE:6379] Redis. Laravel 在 linux 服务器上使用 redis 连接超时 [tcp://127.0.0.1:6379] - Connection timed out [tcp://127.0.0.1:6379] using redis on linux server Laravel 通过 Redis 排队:local.ERROR:连接到 127.0.0.1:6379 时出现读取错误 - Laravel Queue via Redis: local.ERROR: read error on connection to 127.0.0.1:6379 Redis 向服务器写入字节时出错。 [tcp://127.0.0.1:6379] - Redis Error while writing bytes to the server. [tcp://127.0.0.1:6379] 连接被拒绝:无法连接到 127.0.0.1 端口 4444:连接被拒绝 laravel 黄昏与 selenium 和 laradock - Connection Refused : Failed to connect to 127.0.0.1 port 4444: Connection refused laravel dusk with selenium and laradock TCP套接字中的“连接被拒绝”? - 'Connection refused' in tcp socket? TCP 提供程序连接被拒绝 - Laravel 6 和 SQL 服务器 (Microsoft) 和 Laragon - TCP Provider connection refused - Laravel 6 and SQL Server (Microsoft) and Laragon SQL连接被Laravel拒绝 - SQL Connection refused with Laravel Laravel Connection拒绝错误 - Laravel Connection Refused Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM