zoukankan      html  css  js  c++  java
  • redis Connection refused 远程连接错误

    redis 远程连接时报错: 
    Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect 
    (redis 安装在ubuntu 系统)
     
    - 1.首先,我们要把防火墙禁用掉
    - 2.安装redis时,Redis 的配置文件默认是绑定本地ip的,所以我们要去系统中找到bind 127.0.0.1,
    然后把它注释掉,那么就可以连接上了
    - 3.下面是redis.conf配置文件,看到bind 127.0.0.1吗?就是他,搞我们连接不上,注释掉吧

    # Redis configuration file example
    
    # Note on units: when memory size is needed, it is possible to specifiy
    # it in the usual form of 1k 5GB 4M and so forth:
    #
    # 1k => 1000 bytes
    # 1kb => 1024 bytes
    # 1m => 1000000 bytes
    # 1mb => 1024*1024 bytes
    # 1g => 1000000000 bytes
    # 1gb => 1024*1024*1024 bytes
    #
    # units are case insensitive so 1GB 1Gb 1gB are all the same.
    
    # By default Redis does not run as a daemon. Use yes if you need it.
    # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
    daemonize yes
    
    # When running daemonized, Redis writes a pid file in /var/run/redis.pid by
    # default. You can specify a custom pid file location here.
    pidfile /var/run/redis/redis-server.pid
    
    # Accept connections on the specified port, default is 6379.
    # If port 0 is specified Redis will not listen on a TCP socket.
    port 6379
    
    # If you want you can bind a single interface, if the bind option is not
    # specified all the interfaces will listen for incoming connections.
    #
    bind 127.0.0.1
    
    # Specify the path for the unix socket that will be used to listen for
    # incoming connections. There is no default, so Redis will not listen
    # on a unix socket when not specified.
    #
    # unixsocket /var/run/redis/redis.sock

    - 4.注释后,再重启redis服务器 sudo /etc/init.d/redis-server restart (不重启,你修改的配置不会生效)

     
  • 相关阅读:
    KVM + LinuxBridge 的网络虚拟化解决方案实践
    netfilter/iptables 防火墙
    Linux 的路由功能
    使用 tcpdump 抓包分析 TCP 三次握手、四次挥手与 TCP 状态转移
    the quieter you become,the more you could see.
    ghost和WINHEX磁盘备份功能的区别
    快速格式化和非快速格式化
    软件是如何控制硬件的?
    如何思考一个问题?
    遇到劣质空气开关了
  • 原文地址:https://www.cnblogs.com/cloudshadow/p/redis_connect_error.html
Copyright © 2011-2022 走看看