FG
🗄️ Databases

初始化的时候报错,急~~~

Freshabout 21 hours ago
Mar 14, 20260 views
Confidence Score51%
51%

Problem

【代码】 _this.redis = new _ioredis2.default(6379,RDS_HOST,{password:RDS_PWD,dropBufferSupport:true}); 【报错】 [ioredis] Unhandled error event: ReplyError: ERR AUTH Authentication password incomplete.The password is instanceid:password, example: 05719bf0c3ae11e4:123456. at JavascriptReplyParser.returnError (/opt/node-publish/study/node_modules/ioredis/lib/redis/parser.js:25:25) at JavascriptReplyParser.run (/opt/node-publish/study/node_modules/redis-parser/lib/javascript.js:135:18) at JavascriptReplyParser.execute (/opt/node-publish/study/node_modules/redis-parser/lib/javascript.js:112:10) at Socket.<anonymous> (/opt/node-publish/study/node_modules/ioredis/lib/redis/event_handler.js:107:22) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) at TCP.onread (net.js:543:20)

Error Output

error event: ReplyError: ERR AUTH Authentication password incomplete.The password is instanceid:password, example: 05719bf0c3ae11e4:123456.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix Redis Authentication Error by Correcting Password Format

Medium Risk

The error occurs because the provided password for Redis authentication is incomplete. The expected format for the password is 'instanceid:password', but the current implementation may not be supplying it correctly, leading to an authentication failure.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Check RDS_HOST and RDS_PWD Variables

    Ensure that the RDS_HOST and RDS_PWD environment variables are correctly set. The RDS_PWD should contain the full authentication string in the format 'instanceid:password'.

    typescript
    console.log('RDS_HOST:', process.env.RDS_HOST); console.log('RDS_PWD:', process.env.RDS_PWD);
  2. 2

    Update Redis Initialization Code

    Modify the Redis initialization code to ensure that the password is formatted correctly. If RDS_PWD is not in the required format, concatenate the instance ID and password appropriately.

    typescript
    _this.redis = new _ioredis2.default(6379, RDS_HOST, { password: `${INSTANCE_ID}:${RDS_PWD}`, dropBufferSupport: true });
  3. 3

    Test Redis Connection

    After updating the password format, test the Redis connection to verify that authentication is successful. You can do this by attempting to set and get a simple key-value pair.

    typescript
    _this.redis.set('test_key', 'test_value').then(() => _this.redis.get('test_key')).then(value => console.log(value));
  4. 4

    Handle Errors Gracefully

    Implement error handling to catch any authentication errors and log them for easier debugging in the future. This will help identify issues quickly if they arise again.

    typescript
    _this.redis.on('error', (err) => { console.error('Redis error:', err); });

Validation

Confirm that the Redis connection is established without errors by checking the console logs for successful key-value operations. Additionally, ensure that no authentication errors are logged.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

redisiorediscachequestion