美文网首页
解决windows本地无法连接Redis服务器问题

解决windows本地无法连接Redis服务器问题

作者: i_cyy | 来源:发表于2019-08-08 11:03 被阅读0次

最近碰到一个Redis一直无法访问本地host设置的一个 redis.com的问题,但是换成127.0.0.1就能连接成功,经过了解,是Redis配置文件中默认设置了bind 127.0.0.1的原因。

解决办法:

修改本地Redis配置文件 redis.conf

################################## NETWORK #####################################

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# bind 127.0.0.1  
bind 0.0.0.0

改完配置文件后发现重启Redis服务无效,(Ps:自己将Redis做成了本地服务)

下面是安装和卸载Redis服务的命令,在redis-server.exe所在的目录下cmd执行下面命令即可:

 安装redis为服务:
            redis-server.exe --service-install redis.windows.conf --loglevel verbose 
 卸载redis服务:
            redis-server --service-uninstall

修改完成后,手动启动下本地服务的Redis服务,再次连接,问题解决。

相关文章

网友评论

      本文标题:解决windows本地无法连接Redis服务器问题

      本文链接:https://www.haomeiwen.com/subject/jlitjctx.html