Search code examples
ddev

How can I find out what's going wrong with a ddev container, or see the logs?


I'm working on a project using ddev and I don't know how to troubleshoot things because they're hidden in the containers they run in. For example, I've tried ddev logs but it doesn't give me enough information.


Solution

  • Use ddev list and ddev describe to get the general idea of what's going on, but then ddev logs is the first line of investigation. It gets the logs of the web container (both the nginx error log and the php-fpm error log, mixed together).

    Extra approaches:

    • Assuming your project is under source control, try temporarily removing any custom nginx/php/mysql/Dockerfile configuration that you might have added to the project in the .ddev folder, as those are common culprits. cd .ddev && rm -r nginx nginx_full apache php mysql web-* mutagen traefik xhprof && ddev restart. If it works after that, you can use git diff to explore what you changed that might have broken it.
    • ddev logs -f will "follow" the web logs, so you can see what happens when you hit a particular URL.
    • ddev logs -s db (or of course ddev logs -f -s db will show you the logs of the database container (MariaDB logs)
    • Use ddev ssh (for the web container) or ddev ssh -s db (for the db container) to actually go in there and look around. The most important logs are in /var/log/ and /var/log/nginx.

    You can even use ddev logs when a container has crashed or stopped for some reason, and figure out what happened with it.

    Don't forget the troubleshooting section in the docs.