8

I've setup an Ubuntu image on VirtualBox on a Windows 7 host. On the Ubuntu guest I've installed Redis which runs on port 6379 (TCP) by default.

I've setup port forwarding using the VirtualBox GUI for SSH and verified that by connecting to localhost:2222 the connection is properly forwarded to port 22 and SSH works.

However, when I completed the same setup for port 6379 I get a "telnet: Unable to connect to remote host: Connection refused" error when connecting port 30000, which is setup to forward to 6379.

Just to verify that the Redis was running correctly I verified that I can connect locally (via the command line on the guest machine) to Redis using port 6379 (telnet localhost 6379) and successfully ran commands against it.

I'm at a bit of a loss as to why this is happening. Any input would be great.

mep-um
  • 195
  • 1
  • 1
  • 4

3 Answers3

10

Find your redis.conf file and comment out the line that reads Bind 127.0.0.1. Most out of the box installs have the interface only excepting local connections. Once you comment that out and restart redis server you will be able to connect assuming no other firewall is keeping from getting in

On Ubuntu Linux you can go location /etc/init.d and issue the this command to restart redis server.

sudo ./redis-server restart

or

sudo  /etc/init.d/redis-server restart
Kuberchaun
  • 256
  • 2
  • 5
8

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:

sudo /etc/init.d/redis restart

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

redis-cli -h 192.168.x.x ping

if you get PONG it's ok.

Hieu Le
  • 181
  • 1
  • 2
  • This did the trick, however in my case it was not `redis` but `redis-server` and I had to do everything with `sudo su` first. But now I get `PONG`. Thanks. – Matt Komarnicki Jun 04 '18 at 05:27
0

Under Redis config file:
/etc/redis/redis.conf

Change the following:

bind 127.0.0.1 ::1

Replace with the below:

0.0.0.0

Save the file

Try the following command from another pc/server server:

redis-cli -h x.x.x.x -p 6379

where x.x.x.x is replaced by your server IP

kenlukas
  • 2,886
  • 2
  • 14
  • 25