0

I am using Laravel + Docker and I have a container for Redis. But when I run locally php artisan list then I get this error. I want to run this command locally (not in container), I already did composer install locally.

The reason I want to do this on my local machine is so that I could run other artisan commands on my machine (like create a new controller or model). It also helps with intelisense.

$ php artisan list

Predis\Connection\ConnectionException 
php_network_getaddresses: getaddrinfo failed: No such host is known. [tcp://myapp-redis-server:6379]

If I change it to localhost, I get a different error REDIS_HOST=localhost

$ php artisan list

Predis\Connection\ConnectionException 
No connection could be made because the target machine actively refused it. [tcp://localhost:6379]
Liga
  • 3,291
  • 5
  • 34
  • 59
  • There are not much details. Apparently, your Docker doesn't forward Redis port from external to internal. Can you share output of these commands: `docker ps` and `netstat -tpln` – Adil Feb 03 '21 at 11:03
  • Not sure if https://stackoverflow.com/questions/37242217/access-docker-container-from-host-using-containers-name helps. – Nigel Ren Feb 03 '21 at 11:04
  • I guess I didn't need to run it locally after all, I could run them all through a container and it worked `docker exec -it app-php-server php artisan list` – Liga Feb 03 '21 at 12:06

0 Answers0