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

Problem

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.

  • How to use `docker-machine create` so that the docker engine listens on a custom port?
  • Docker drop changes on restart
  • minikube : not able to connect a locally deployed nginx service
  • Start supervisor by non root user
  • Using Consul, how can I assign domain names to containers?
  • (mac) dockers , commit changes in mongo doesn't work
  • So, I’m not able to run the debugger, but it did work previously (!). Not able to pinpoint why it suddenly stopped working.

    Setup

    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:

    zend_extension=xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_host=10.0.2.2
    xdebug.remote_connect_back=0
    xdebug.remote_port=5555
    xdebug.idekey=complex
    xdebug.remote_handler=dbgp
    xdebug.remote_log=/var/log/xdebug.log
    xdebug.remote_autostart=1
    

    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 10.0.2.2
    

    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 10.0.2.2 5555
    

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

    • Running: Connection to 10.0.2.2 5555 port [tcp/*] succeeded!
    • Not running: nc: connect to 10.0.2.2 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 😀

  • WordPress docker compose won't start mysql
  • installation of nodejs returned a non-zero code: 1 with docker build
  • How do you set encrypted Travis env variables in docker?
  • Using docker environment -e variable in supervisor
  • Docker container does not start on executing docker run command
  • Is it acceptable to create tests relying on docker for a node.js module?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.