node-redis:ErrorReply: ERR wrong number of arguments for ‘auth‘ command

本文涉及的产品
云数据库 Tair(兼容Redis),内存型 2GB
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
简介: node-redis:ErrorReply: ERR wrong number of arguments for ‘auth‘ command

问题描述

环境

$ node -v
v16.14.0
# redis-cli
127.0.0.1:6379> info
# Server
redis_version:5.0.5

版本 package.json

{
  "dependencies": {
    "redis": "^4.2.0"
  }
}

代码

import { createClient } from 'redis'
const REDIS_URL = "redis://root:123456@127.0.0.1:6379"
export async function getRedisClient() {
  // 连接redis
  const client = createClient({
    url: REDIS_URL,
  })
  await client.connect()
  return client
}

报错

node:internal/process/promises:265
            triggerUncaughtException(err, true /* fromPromise */);
            ^
[ErrorReply: ERR wrong number of arguments for 'auth' command]

解决办法

明明是按照格式写的,却报错了

redis[s]://[[username][:password]@][host][:port][/db-number]

按照github上的issues,如果是默认username, 那么需要省略

const REDIS_URL = "redis://:123456@127.0.0.1:6379"

参考

https://github.com/redis/node-redis/issues/1591


相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
相关文章
|
1月前
|
JavaScript
nodejs安装之npm ERR! code CERT_HAS_EXPIREDnpm ERR! errno CERT_HAS_EXPIRED reason: certificate has expired-证书错误通用问题解决方案-优雅草央千澈
nodejs安装之npm ERR! code CERT_HAS_EXPIREDnpm ERR! errno CERT_HAS_EXPIRED reason: certificate has expired-证书错误通用问题解决方案-优雅草央千澈
220 26
|
6月前
|
缓存 NoSQL Redis
【Azure Redis 缓存】Redission客户端连接Azure:客户端出现 Unable to send PING command over channel
【Azure Redis 缓存】Redission客户端连接Azure:客户端出现 Unable to send PING command over channel
317 3
|
5月前
|
小程序 PHP
微信小程序给 thinkphp后端发送请求出现错误 Wrong number of segments 问题的解决 【踩坑记录】
本文记录了微信小程序向ThinkPHP后端发送请求时出现"Wrong number of segments"错误的解决方法。问题原因是小程序请求header中的token变量名写错,导致token未正确传递至后端。作者提供了详细的检查步骤和建议,包括验证URL路径、参数规范和路由配置的匹配,以确保请求能正确发送和处理。
|
6月前
|
缓存
Node——npm ERR! cb() never called!
Node——npm ERR! cb() never called!
104 0
|
NoSQL Java Redis
redis.clients.jedis.exceptions.JedisDataException: ERR Syntax error, try CLIENT (LIST | KILL ip:port
redis.clients.jedis.exceptions.JedisDataException: ERR Syntax error, try CLIENT (LIST | KILL ip:port
|
NoSQL 安全 Redis
【Redis异常】redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password
【Redis异常】redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password
393 0
|
9月前
|
缓存 NoSQL 中间件
redis内存溢出报错--OOM command not allowed when used memory > 'maxmemory'
该内容是关于Redis缓存服务器的使用指南。通过Xshell连接IP地址为25.218.153.193或206的主机,进入/data/iuap/middleware/redis-30001/bin目录,使用`redis-cli`连接到IP为206的30003端口。登录时需`auth yonyou*123`,可运行`info`和`info memory`查看状态,`flushall`清理缓存。在清理前,要备份/data/iuap/middleware/redis-30003/data/下的.aof和.rdb文件,利用tar命令打包并移至/tmp目录。
|
NoSQL Java 测试技术
Springboot2.x集成lettuce连接redis集群报超时异常Command timed out after 6 second(s)
最近在对一新开发Springboot系统做压测,发现刚开始压测时,可以正常对redis集群进行数据存取,但是暂停几分钟后,接着继续用jmeter进行压测时,发现redis就开始突然疯狂爆出异常提示:Command timed out after 6 second(s)......
470 0
|
JavaScript
node_modulesnode-sass npm ERR command failed 解决方法
node_modulesnode-sass npm ERR command failed 解决方法
450 0
下载node-gyp依赖包报错:gyp ERR! find VS msvs_version not set from command line or npm config
就是有一点需要注意,我这里安装vs的时候,可用里面没有vs社区版2017,只有2022,只能安装了2022