Open Redis port for remote connections

后端 未结 10 2001
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 10:00

I can ping pong Redis on the server:

# redis-cli ping
PONG

But remotely, I got problems:

$ src/redis-cli -h REMOTE.IP ping
         


        
相关标签:
10条回答
  • 2020-12-07 10:54

    1- Comment out bind 127.0.0.1

    2- set requirepass yourpassword

    then check if the firewall blocked your port

    iptables -L -n

    service iptables stop

    0 讨论(0)
  • 2020-12-07 10:56

    For me, I needed to do the following:

    1- Comment out bind 127.0.0.1

    2- Change protected-mode to no

    3- Protect my server with iptables (https://www.digitalocean.com/community/tutorials/how-to-implement-a-basic-firewall-template-with-iptables-on-ubuntu-14-04)

    0 讨论(0)
  • 2020-12-07 10:57

    Did you set the bind option to allow remote access on the redis server?

    Before (file /etc/redis/redis.conf)

    bind 127.0.0.1
    

    After

    bind 0.0.0.0
    

    and run sudo service redis-server restart to restart the server. If that's not the problem, you might want to check any firewalls that might block the access.

    Important: If you don't use a firewall (iptables, ufw..) to control who connects to the port in use, ANYONE can connect to this Redis instance. Without using Redis' AUTH that means anyone can access/change/delete your data. Be safe!

    0 讨论(0)
  • 2020-12-07 11:02
    1. Open $REDIS_HOME/redis.conf and uncomment requirepass -YOUR-PASSWORD-HERE- and write down your password in the specified lines.

    2. Login to redis using redis-cli and verify your password in the database using auth -YOUR-PASSWORD-HERE- command.

    3. Disable protected mode by changing its string in $REDIS_HOME/redis.conf to protected-mode no.

    4. Search for all bind ports values and comment all of them. Just add bind 0.0.0.0 to $REDIS_HOME/redis.conf file.

    5. Disable your firewall or open redis port.

    6. Start redis using ./redis-server $REDIS_HOME/redis.conf.

    7. Check the configuration via ./redis-cli -h -YOUR-IP- -a -YOUR-PASSWORD-HERE-.

    8. Check the configuration via ./redis-cli -h -YOUR-IP- ping.
    0 讨论(0)
提交回复
热议问题