0

I have just installed Redis on a remote Ubuntu machine (VM configurations) and used port forwarding to be able to access it from a remote client. Redis is working correctly on the machine itself : I am able to get response for 'ping' commands sent through redis-clients on the same machine. However, when I try to access the Redis server from a remote-machine (using a jedis client for a java application), I get a socket time-out error.

On researching the problem a little, I realized that the redis-server on the remote machine is not working as a service. The output of the service command is given below which shows that the redis-server service is currently stopped ([-] option in front of "redis-server").

Also, using netstat command, I have ensured that the port 6379 is assigned to redis-server. Attached below is the snapshot of the same. enter image description here

Also, in my configuration file (redis.conf), I have uncommented the line that binds the server to 127.0.0.1 and also changed the "daemon" option to 'yes'. I start the server using this config file.

Any help on how I can access the remote server (or run the service in the background such that it actively listens for new connections) through my application is highly appreciated! Thanks in advance.

4
  • Edit: I have also changed the binding from 127.0.0.1 to 0.0.0.0 but it also doesn't work Commented Jun 20, 2014 at 9:23
  • You should ideally get the following response : netstat -a | grep 6379 tcp 0 0 :6379 *: LISTEN Commented Jun 22, 2014 at 10:16
  • How do you start your server ? You should ideally start it along with path to your config file where you have made the changes . Look for updated answer. Commented Jun 22, 2014 at 10:18
  • I always start my server with the config file path. I figured out the problem. The port on the remote machine was assigned to redis but was being blocked by the firewall. After opening the port for remote connections, I was able to run it properly. But thanks for you time. I greatly appreciate your help. Commented Jun 23, 2014 at 7:30

2 Answers 2

0

Whether in background or not, Redis does only listen to localhost by default. To make it listen to all IP-Addresses comment out the 'bind'-line completely (prefix with '#').

Just remember: Making Redis publically available (e.g. exposing its port to the Internet) may be a security risk. Redis has no sophisticated integrated security, as you can only set a simple global password. Due to its performance (50000+ gets per second on an anverage machine) this password is very prone to bruteforcing attempts. You can instead use SSH-tunneling to access your redis instance. Just remember to change your bind back to 127.0.0.1 in this case.

Sign up to request clarification or add additional context in comments.

3 Comments

I tried commenting the 'bind' line but no luck. Currently I am binding it to 0.0.0.0 for accessing it globally. Still, nothing works.
First of all, I am glad to hear you got your remote connection up and running. You may however still consider my secure connection approach. I have done so myself for several C# applications and it works like a charm. I am using a C# ssh library to connect to the server redis runs on (on port 22), tunneling the redis port from client-localhost to server-localhost. I then connnected my redis-client on the client machine to localhost and voila: secure encrypted connection. There has to be some easy to use java lib for ssh (I just don't know one by name, I'm not very experienced in java)...
Thanks for the suggestion. I will surely try that! :)
0

All you need to do here is : In your redis.conf file change

bind 127.0.0.1

to

bind 0.0.0.0

and restart your server

sudo src/redis-server

Check this out : Redis - Connect to Remote Server

1 Comment

I tried this also but it doesn't work. Please check the comment below the question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.