Fataho
Fataho

Reputation: 99

Cannot connect from windows to redis linux server

I cannot connect to redis server (ubuntu server 16.04 LTS 64 bits on separate PC) from windows 8.1 64-bits. Redis is well documented, however I found very little information how to connect redis server from separate machine. I have installed latest version of redis into linux and locally everything works fine. I start server via redis-server and also I start redis-cli and after that I am able to add information into server and retrieve it. The same situation is in windows - everything works locally. In order to connect from windows into linux redis server I did these changes. In linux I set the static local IP via sudo nano /etc/network/interfaces

address 192.186.xxx.xxx

netmask 255.255.255.0

network 192.168.xxx.xxx

broadcast 192.168.xxx.xxx

gateway 192.168.xxx.xxx

dns-nameservers 8.8.8.8

In redis.conf file I bind my windows PC IP which is given by my internet service provider. I also opened TCP 6379 port in my router GUI. In windows I modify redis.windows-service.conf and redis.windows.conf files. In both of them I bind my IP address given by my internet service provider. After this I cannot start redis-cli properly (empty black cmd window is visible) What I am doing wrong? I would be very grateful for any help.

Upvotes: 1

Views: 4061

Answers (3)

Filious
Filious

Reputation: 107

I have also experience the same issue trying to connect to Redis (MSOpenTech 3.0.5 and 3.2.1) By default if no binding is stated then redis(according to the comments in the conf file) will listen to all available interfaces. That said, v 3.2.1 does have 'bind 127.0.0.1' already set... in 3.0.5 Setting the binding to 'bind 127.0.0.1' still allows the redis-cli to be used. Binding to 192.168.1.2 renders the redis-cli unusable with both versions - there is no IP and Port prompt, simply a carat and the cli does not accept keyboard input. Binging to an external IP the MSOpenTech fork service will not restart and throws an error(nice). Clearing all bindings and reverting back to original state, the redis-cli becomes usable again. Also, on the MS OpenTech fork there is no 'ProtectedMode' setting in either config file. Not sure whether this can actually be set.

Have raised this as an issue on the MSOpenTech fork via github but expecting silence to be the only reply...

I'm not sure this helps you in any way other than knowing that you are not alone. I am trying to pub from PHP to AS3 subscribers - it works great in the Flash IDE but from the localhost browser, redis appears to go decididly deaf.

Upvotes: 1

GuangshengZuo
GuangshengZuo

Reputation: 4677

You should modify the redis conf, my redis conf is located at /etc/redis/6379.conf.

And you should comment the line "bind 127.0.0.1" Or change to bind 0.0.0.0. The bind specify which network interface the redis server should listen to. The default is localhost.

And also Change the protected-mode to no :

Protected mode is a layer of security protection, in order to avoid that Redis instances left open on the internet are accessed and exploited.

When protected mode is on and if:

1) The server is not binding explicitly to a set of addresses using the "bind" directive.

2) No password is configured.

The server only accepts connections from clients connecting from the IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain sockets.

By default protected mode is enabled. You should disable it only if you are sure you want clients from other hosts to connect to Redis even if no authentication is configured, nor a specific set of interfaces are explicitly listed using the "bind" directive.

protected-mode yes

If you don't disable the protected-mode, your redis server will not listen public ip interface. more detail see above.

Upvotes: 3

Badr Ghatasheh
Badr Ghatasheh

Reputation: 978

If you can access the remote server from your machine, your problem is most probably with redis security config, read the Securing Redis section in this document I found that most of the time people don't change the "bind" directive value in redis config, you can test that by setting bind 0.0.0.0 and restarting redis server, if that's the issue, you can then allow whatever subnets you need to access the server.

Upvotes: 1

Related Questions