隐藏

redis通过6379端口无法连接服务器(redis-server.exe闪退)

发布:2022/9/14 16:29:58作者:管理员 来源:本站 浏览次数:804

程序中报错:Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379

原因是redis没有启动,解决方法:
找到redis安装路径,按如下步骤便可启动redis

按正常情况来说redis便可通过6379端口连接到服务器,我这里报双击redis-server.exe时出现闪退(很多人出现这种现象)

原因是:没有设置redis的最大内存所导致,解决方法:

在redis的配置文件(redis.windows.conf)中加入maxmemory和maxheap配置


再次启动:


而后双击redis-cli.exe便可看到连接成功了

为了方便我们可以配置redis后台运行:

添加进服务

  • 进入 DOS窗口
  • 在进入redis的安装目录 cmd窗口执行一下命令
  • 输入:redis-server --service-install redis.windows.conf --loglevel verbose ( 安装redis服务 )
  • 输入:redis-server --service-start ( 启动服务 )

输入:redis-server --service-stop (停止服务)

成功!!!