Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mlusas's avatar

Redis connection refused for remote connection

I'm having trouble getting a connect when Redis has a bind IP Address. It works when I do not bind any IP Addresses in /etc/redis/redis.conf. But when I bind the IP Addresses, I can no longer connect, even if I'm connecting from one of the bound IP Addresses. Does anyone have an idea what may be going wrong?

I have ensured that UFW allows access to the port.

redisServer$ sudo ufw allow from 192.168.xxx.xx to any port 6379

The /etc/redis/redis.conf bind code is:

bind 127.0.xxx.xx 192.168.xxx.xx  192.168.xxx.xx 104.237.xxx.xx

Here is what I'm using to remotely connect to the Redis server:

visitingServer$ redis-cli -h 192.168.xxx.xx -p 6379 -a "password"
0 likes
2 replies
cchambers's avatar

I'm having this issue currently, any luck with this?

Val's avatar

There are several items to check for a remote connection to work:

  • If redis works locally:
$ redis-cli
127.0.0.1:6379>ping
PONG
127.0.0.1:6379>
  • If the password is not set in /etc/redis/redis.conf (this is default locaion for Ubuntu 18.04, you may have it in the different localtion):
# The following line should be commented
# requirepass <some pass if any>
  • if the protected mode is set to 'no' in the config:
# The following line should be uncommented
protected-mode no
  • if the IP binding is open for an access from internet in the config:
# The following line should be commented
# bind 127.0.0.1 ::1
  • If the Linux firewall (here for Ubuntu 18.04) allows for incoming internet traffic to go to port 6379 (the Redis default port)
# To check if Redis port is open
$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
...
6379/tcp                   ALLOW       Anywhere
6379/tcp (v6)              ALLOW       Anywhere (v6)
...

# To open the port
$ sudo ufw allow 6379/tcp

Do not forget to restart the Redis service for changes to take effect and check if it is running:

$ sudo systemctl restart redis.service
$ sudo systemctl status redis

Then to check if it works from the remote serever you can use redis-cli:

$ redis-cli -h <your-redis-server-ip>
<your-redis-server-ip>:6379> ping
PONG
<your-redis-server-ip>:6379> exit
$

If you can ping-PONG your redis server via your internet server connected as a remote server than the remote redis connection works.

Some links to help How to install and secure Redis on Ubuntu 18.04 and how to setup Ubuntu 18.04 firewall.

WARNING: the above makes your Redis data to be completely open to anybody from the internet.

To basically secure it use requirepass and protected-mode yes settings in Redis config (see above) and block the dangeroush Redis commands (see the link above), for a deeper understanding see this article and Redis site security section.

Hope it helps.

Please or to participate in this conversation.