Nginx + php-fpm: Bad gateway only when xdebug server is running


When xdebug server is running from IntelliJ IDEA, I get 502 Bad Gateway from nginx when I try loading my site to trigger breakpoints.

If I stop the xdebug server, the site works as intended.

  • Gtk cannot display window while using docker
  • Single versus multiple containers
  • How to know if my program is completely started inside my docker with compose
  • Setting volumes in docker-compose.yml file for windows 10 home
  • Apache gSOAP + Docker
  • What is the easiest way to export a Docker container to VM
  • So, I’m not able to run the debugger, but it did work previously (!). Not able to pinpoint why it suddenly stopped working.


    A short explanation of the setup (let me know if I need to expand on this).

    My php app is running in a docker container, and it is linked to nginx running in a different container using volumes_fromin the docker compose config.

    After starting the app, I can verify using phpinfo(); the xdebug module is loaded.

    My xdebug.ini has the following content:

    I got the ip address for remote_host (where the xdebug server is running) by these steps:

    docker-machine ssh default
    route -n | awk '/UG[ \t]/{print $2}' <-- Returns

    To verify I could reach the debugging server from within my php container, I did the following steps

    docker exec -it randomhash bash
    nc -z -v 5555

    Giving the following output depending on xdebug server running or not:

    • Running: Connection to 5555 port [tcp/*] succeeded!
    • Not running: nc: connect to port 5555 (tcp) failed: Connection refused

    So IntelliJ IDEA is surely set up to receive connections on 5555. I also did the appropriate path mapping between my source file paths and the remote path (when setting up the PHP Remote Debugging server from within IDEA).

    Any ideas? Kind of lost on this one as I don’t have much experience with any of these technologies 😀

  • How to setup jenkins blue ocean under Windows with docker agent
  • Issue with docker Inter container communication on the isolated bridge
  • Patterns for Docker DB Snapshot
  • Running docker containers behind loadbalancer, ports not forwarded as expected
  • Go-compiled binary won't run in an alpine docker container on Ubuntu host
  • How to send messages to a sub socket running in docker container from host?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.