Redis - Connect to Remote Server

前端 未结 7 487
悲&欢浪女
悲&欢浪女 2020-12-04 05:31

I\'ve just install Redis succesfully using the instructions on the Quick Start guide on http://redis.io/topics/quickstart on my Ubuntu 10.10 server. I\'m running the service

相关标签:
7条回答
  • 2020-12-04 06:04

    Orabig is correct.

    You can bind 10.0.2.15 in Ubuntu (VirtualBox) then do a port forwarding from host to guest Ubuntu.

    in /etc/redis/redis.conf

    bind 10.0.2.15
    

    then, restart redis:

    sudo systemctl restart redis
    

    It shall work!

    0 讨论(0)
  • 2020-12-04 06:10

    I've been stuck with the same issue, and the preceding answer did not help me (albeit well written).

    The solution is here : check your /etc/redis/redis.conf, and make sure to change the default

    bind 127.0.0.1
    

    to

    bind 0.0.0.0
    

    Then restart your service (service redis-server restart)

    You can then now check that redis is listening on non-local interface with

    redis-cli -h 192.168.x.x ping
    

    (replace 192.168.x.x with your IP adress)

    Important note : as several users stated, it is not safe to set this on a server which is exposed to the Internet. You should be certain that you redis is protected with any means that fits your needs.

    0 讨论(0)
  • 2020-12-04 06:10

    In addition to the excellent answer given by Orabîg:

    I resolved this issue by removing the bind section entirely and setting protected-mode to no.

    #bind 127.0.0.1
    protected-mode no
    

    Never use this method on publicly exposed servers.

    0 讨论(0)
  • 2020-12-04 06:12
    • if you downloaded redis yourself (not apt-get install redis-server) and then edited the redis.conf with the above suggestions, make sure your start redis with the config like so: ./src/redis-server redis.conf

      • also side note i am including a screenshot of virtual box setting to connect to redis, if you are on windows and connecting to a virtualbox vm.

    0 讨论(0)
  • 2020-12-04 06:16

    Setting tcp-keepalive to 60 (it was set to 0) in server's redis configuration helped me resolve this issue.

    0 讨论(0)
  • 2020-12-04 06:24

    First I'd check to verify it is listening on the IPs you expect it to be:

    netstat -nlpt | grep 6379
    

    Depending on how you start/stop you may not have actually restarted the instance when you thought you had. The netstat will tell you if it is listening where you think it is. If not, restart it and be sure it restarts. If it restarts and still is not listening where you expect, check your config file just to be sure.

    After establishing it is listening where you expect it to, from a remote node which should have access try:

    redis-cli -h REMOTE.HOST ping
    

    You could also try that from the local host but use the IP you expect it to be listening on instead of a hostname or localhost. You should see it PONG in response in both cases.

    If not, your firewall(s) is/are blocking you. This would be either the local IPTables or possibly a firewall in between the nodes. You could add a logging statement to your IPtables configuration to log connections over 6379 to see what is happening. Also, trying he redis ping from local and non-local to the same IP should be illustrative. If it responds locally but not remotely, I'd lean toward an intervening firewall depending on the complexity of your on-node IP Tables rules.

    0 讨论(0)
提交回复
热议问题