502 Bad Gateway when debugging php 7 Xdebug 2.4.0RC3 mac os 502 Bad Gateway when debugging php 7 Xdebug 2.4.0RC3 mac os nginx nginx

502 Bad Gateway when debugging php 7 Xdebug 2.4.0RC3 mac os


You can try this:open your php.ini, sorry I don't know where it's placed in MacOS, in Ubuntu it is on

/etc/php/7.0/fpm/php.ini

open it with your favourite text editor with needed privileges to save config files.Goto xdebug section and check if you've set it up correctly. In my case it looks like down below. Note that path to xdebug.so in your case could be different.

[Xdebug]zend_extension="/usr/lib/php/20151012/xdebug.so"xdebug.remote_enable=1xdebug.remote_port=9000xdebug.profiler_enable=1xdebug.profiler_output_dir="\tmp"xdebug.idekey="PHPSTORM"xdebug.remote_autostart=1xdebug.remote_host=192.168.10.10xdebug.remote_mode=reqxdebug.remote_connect_back=1xdebug.max_nesting_level=200xdebug.var_display_max_depth=1000xdebug.var_display_max_children=256xdebug.var_display_max_data=4096;this line below to prevent debug stop timeoutrequest_terminate_timeout=600s

Another thing to check in php.ini is

max_execution_time = 600

I've set it in seconds as above to prevent stopping debugging session by default it's set to 30 sec

Next thing you need to check is nginx configuration I've added to main nginx.conf http section those lines

http {    proxy_connect_timeout 600s;    proxy_send_timeout 600s;    fastcgi_read_timeout 600s;    proxy_read_timeout 600s;    fastcgi_buffers 8 16k;    fastcgi_send_timeout 600s;    fastcgi_buffer_size 32k;   #other standard settings below...

I've added them to give me more time for debugging session so it will not be stopped in 600sec.

After all editing.Restart php7.0-fpm and nginx.I'm not sure how it's done in MacOS in Ubuntu it is done through:

 sudo service php7.0-fpm reload sudo service php7.0-fpm restart sudo service nginx reload sudo service nginx restart

Maybe it's overkill to reload and then restart but to be insured :)

Also take a look at your error.log files for nginxIn Ubuntu they are placed in /var/logs/nginx/ there is error.yourdomain.log go to the last lines and see what has happened.Hope it'll helps.

UPD: For anyone who will use Homestead with ngrok tunnel (or for example ssh -R 3000:localhost:8000 user@yourserver.domain and then on public site you'll setup nginx as a reverse proxy for somedomain on port 80 to read from 3000 tunneled via SSH) to expose local development to internet.

To enable debugging you need to comment out line xdebug.remote_connect_back=1 or set it's value to 0. Otherwise xdebug will get X-Forwarded-For and other headers and will try to connect back to nginx but not to your local dev, and debugging will not start.