18

What is the bind parameter in Redis? The documentation for bind assumes that I already know what bind means (which I don't). Does bind set the IP address of:

  • the Redis server? (I think this is the correct answer, but then I don't understand why we need that)
  • the client that will be authorized to connect to Redis? (I tried and it didn't work, so probably incorrect)
usual me
  • 8,338
  • 10
  • 52
  • 95

2 Answers2

21

It's the redis equivalent of mysql bind-address option and works in exactly the same way.

It binds the redis instance to specific interface (and hence specific ip address).

Basically your redis server will only listen to connections made to the address specified in via the bind option. This is a security measure that allows for dropping connections not made inside the particular network.

So if you set

bind 127.0.0.1

redis will only accept client connections made to 127.0.0.1 (only local ones).

If you set it to

bind 0.0.0.0

it will accept connection to any address (and hence any connection that can be made to your redis instance) that is used by any interface on the machine where redis is running.

If you set it to any other specific address then redis will expect connections to be made to that specific address and will drop the rest.

soulcheck
  • 36,297
  • 6
  • 91
  • 90
  • 3
    I don't understand the sentence "it will accept connection to any address". Why / when would you accept connections to an address that is neither 127.0.0.1 nor the IP address of the server itself? How can this happen? – usual me Aug 21 '14 at 12:53
  • 1
    It means that it will accept connections to any address assigned to any interface on the redis machine, as there are no other addresses it can receive on. – soulcheck Aug 21 '14 at 13:03
0

Open the redis.conf as a root user by typing command in the terminal, such as:nano /etc/redis/redis.conf and comment the line e.g

#bind 0.0.0.0. 

By doing this you'll be able to connect to redis-server through every remote PC.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Abdul
  • 17
  • 3