Server throwing below error may be on heavy site traffic or loss of redis connection.
But unable to found the cause of this error that can help to resolve.
Also server stops due to below errors at specific UK time around every day at 4 AM.
So any help regarding this will be helpful.
Server : Digital Ocean
Frontend : React JS
Backend : laravel (5.8)
Used spiritix/lada-cache library for mysql cashing to manage large amount of data.
Application is running on Docker containers.
1) error:
production.ERROR: php_network_getaddresses: getaddrinfo failed: Name
or service not known [tcp://redis:6379] {“exception”:”[object] (PredisConnectionConnectionException(code: 0):
php_network_getaddresses: getaddrinfo failed: Name or service not
known [tcp://redis:6379] at
/var/www/vendor/predis/predis/src/Connection/AbstractConnection.php:155)2) error :-
Redis – LOADING Redis is loading the dataset in memory:
3) error :-
production.ERROR: Connection refused [tcp://127.0.0.1:6379]
This error will stops the server as well.
I have tried to restart docker down containers on cron scheduler. But the actual issue is not with docker container, some internal laravel packages like Predis | Ladacash throwing above error for that unable to find exact solution.
2
Answers
Since you are using docker, you no longer should refer to your redis server (docker container) using an IP (say 127.0.0.1). Instead use the container name.
1) Run:
docker ps
to list all containers, then find the redis server, and copy and paste the name undercontainer name
column to your.env
file as the host.2) Make sure that both your app container and redis container are in the same network:
A bit irrelevant as it could be a lot of causes to this problem but in my 2 cases I’ve solved this problem by:
php artisan config:cache
and reloads the env file into cache:php artisan config:clear