连不上阿里云服务器redis

防火墙添加了6379但是连不上

-DENIED Redis is running in protected mode because protected mode is enabled and no password is set for the default user. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Set up an authentication password for the default user. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.

遗失对主机的连接。


原因:

这段英文是 Redis 给出的错误提示,指出因为启用了保护模式且未为默认用户设置密码,所以 Redis 当前运行在保护模式下,仅接受来自环回接口的连接,拒绝外部计算机的连接,并提供了以下几种解决方案3:

  1. 临时禁用保护模式(不推荐在生产环境使用)
    • 登录到运行 Redis 服务器的同一台主机。
    • 使用redis - cli命令行工具连接到本地 Redis 服务。
    • 执行命令CONFIG SET protected - mode no来暂时关闭保护模式。
    • 为了确保配置更改在 Redis 重启后仍然有效,执行CONFIG REWRITE命令以将当前配置写入配置文件。
  2. 永久性地在配置文件中禁用保护模式(强烈不推荐在生产环境使用)
    • 编辑 Redis 的配置文件(通常名为redis.conf),找到protected - mode配置项并将其值更改为no
    • 保存配置文件并退出编辑器。
    • 重启 Redis 服务,新的配置将在 Redis 启动时生效。
  3. 通过命令行参数启动 Redis 时禁用保护模式(仅限于测试场景) :如果是在测试环境中手动启动 Redis 服务器,可以在启动命令中添加--protected - mode no参数来启动 Redis,这样它就不会启用保护模式。
  4. 推荐方案:为 Redis 设置认证密码
    • 在 Redis 配置文件中加入一行requirepass yourpassword,将yourpassword替换为一个强密码。
    • 保存配置文件并重启 Redis 服务,使新密码设置生效。
    • 当从外部客户端连接时,需要提供这个密码进行身份验证。

在实际应用中,出于安全性考虑,建议采用第四种方法,即为 Redis 设置密码而非彻底禁用保护模式,这将确保只有经过授权的客户端才能访问 Redis 实例,同时保留了保护模式提供的基本安全防护层3。

检查服务器端口是否能用命令:

复制代码
telnet <服务器 IP 地址> 6379

很遗憾以上并不行最终解决办法:

相关推荐
hexu_blog6 分钟前
记录一下阿里云OSS直接通过web端或者其他的前端上传文件时,bucket配置过程
阿里云·云计算
Flying pigs~~12 分钟前
企业级模块化RAG项目(mysql➕redis➕milvus➕模型微调➕bm25➕fastapi➕ollama➕Prompt➕多策略选择)
人工智能·redis·mysql·docker·prompt·milvus·rag
志栋智能13 分钟前
超自动化运维如何重塑IT组织的核心竞争力?
运维·服务器·网络·数据库·人工智能·自动化
.select.20 分钟前
TCP 7 (滑动窗口,流量控制)
服务器·网络·tcp/ip
@insist12320 分钟前
网络工程师-交换机核心配置完全指南
运维·服务器·网络·网络工程师·软考·软件水平考试
handler0122 分钟前
Linux基础知识(1)
linux·服务器·c语言·开发语言·数据结构·c++
齐潇宇24 分钟前
LVS 基线检查与安全加固指南(附案例)
服务器·网络·php
ん贤26 分钟前
手敲Linux命令
linux·运维·服务器
程序员雷欧30 分钟前
Redis进阶知识全解析:高可用部署与数据一致性实战
数据库·redis·缓存
爱学习的小囧34 分钟前
SXi LAG 链路聚合负载均衡配置全教程 | LACP 协议 + 交换机联动,新手也能落地
运维·服务器·php·负载均衡·esxi