Skip to content
Advertisement

Docker – Nginx, PHP, MongoDB – Laravel artisan migrate connection timeout

I have Laravel running in Docker with 6 containers – Nginx, MongoDB, PHP, Composer, Npm and Artisan.

Here is my docker-compose-yaml :

JavaScript

Here is my Laravel database config :

JavaScript

And here is my mongodb part in the .env file :

JavaScript

I want to run php artisan migrate, so I run this :

JavaScript

But it give me this error :

JavaScript

I’ve tried changing some configs like ports, host, .. but the error is still here. Does anyone have an idea ?

Advertisement

Answer

Has two solutions to that:

  1. Put the service mongodb on the same network of the others services.
  2. To use the exposed port on host, in to laravel configuration, do you need put 0.0.0.0 the host of mongodb.
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement