How to Fix Redis is unreachable

How to Fix Redis is unreachable

Redis is typically used to improve the performance of web applications and other high-speed requirements because it stores data like cache and NoSQL databases in RAM, which provides very fast data access.

But what if you get a Redis is unreachable error message when trying to use this feature?

Here we will discuss the steps you can take to resolve this Redis is unreachable issue.

How to Fix Redis is unreachable

Some of these steps may require configuration and checks on the server side. If you are using shared hosting, you can ask your hosting provider directly.

1. Ensure the PHP Redis Extension is Active

If you are using Redis for a website like WordPress, you need to ensure that the Redis extension is active.

For example, if you are using cPanel, you can enable the Redis extension from the Select PHP Version > Extensions

2. Check the Redis Port

The first thing you can do is check and ensure that the Redis port is open, for example by using netstat

sudo netstat -lntu | grep 6379

By default, Redis uses port 6379, but if this port is closed, you need to check the firewall configuration on the server and open that port, for example with UFW

sudo ufw allow 6379/tcpsudo ufw reload

Alternatively, you can use firewall-cmd

sudo firewall-cmd --zone=public --add-port=6379/tcp --permanentsudo firewall-cmd --reload

3. Ensure Redis is Installed and Active

If the port is open but you still cannot connect, ensure that Redis is installed and active on the server you are using

sudo systemctl status redis

If the Redis status is not found, you can install Redis first, for example on Ubuntu

sudo apt install redis-serversudo apt install php-redis

However, if it is already installed but the status is stopped, you can start Redis and enable it so it automatically starts when the system reboots

sudo systemctl start redissudo systemctl enable redis

4. Check the Redis Configuration File

Ensure the Redis configuration file is still saved on the server, which is usually stored in /etc/redis/redis.conf. If you cannot find this file, you can copy the default configuration file from the Redis page according to the version of Redis you are using.

5. Check the Redis Logs

Cara Mengatasi Redis is unreachable - 5

If you have tried everything and it is still showing an error, you can check the Redis logs for more information on the cause of the error

sudo tail /var/log/redis/redis-server.log -n 100

6. Restart Redis

Usually, you only need to restart the service when there is an error, and you can try this method as well

sudo systemctl restart redis

Those are some ways you can resolve the Redis is unreachable error. Since this error usually requires you to check directly from the server as mentioned at the beginning, if you are using shared hosting that does not have direct server access, you can ask your hosting provider.

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...