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 connect mysql workbench to running mysql inside docker?
  • Figure out IP address within docker container
  • Redirect application logs to docker logs
  • ASP.NET docker image exposed ports are closed
  • Why is APCu segfaulting inside a Docker container?
  • Why does docker list two separate images (one of which doesn't exist) for my container?
  • 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 😀

  • Node.js zlib gzip buffer as “file” inside of archive
  • send keys to terminal
  • Airflow Docker Deployment: Task Not Getting Run After start_date + schedule_interval
  • Manage a cassandra database on docker with opscenter
  • Should Docker Swarm Master be separate physical node?
  • Spark nodes communicating using wrong IP address (Docker)
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.