Categories
Fix PHP Web

Xdebug with Built-in PHP Server

When using Xdebug with the built-in PHP server be sure you have the proper configuration in your php.ini file. Will will need at a minimum the following settings:

xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.idekey = PHPSTORM
xdebug.remote_host = 127.0.0.1

# Do not assume port 9000 is free
xdebug.remote_port = 9000

If you run into an issue running Xdebug via PHPStorm, or another IDE, when using the built-in PHP server on macOS, or Ubuntu, you might have a conflicting port 9000 with php-fpm.

You can check the 9000 port using the following command on:

sudo lsof -i tcp:9000

To check the port php-fpm occupies use the following command:

sudo lsof -i -n -P|grep php-fpm

Xdebug and php-fpm, or another service, might both be running on port 9000. The simple fix for this is to change the Xdebug port to 9001.

xdebug.remote_port = 9001

Then in PHPStorm set the Xdebug port to 9001 under Preferences | Languages & Frameworks | PHP | Debug

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.