48
votes

Updated question : PhpStorm | WebMatrix (IISExpress) | Xdebug.remote_port | — Which Port(s) to put where?


I'm running localhost web server on my Windows machine with WebMatrix and IISExpress. I've installed PHP and Xdebug in it and they both are working.

I have a local WordPress install.

I'm now trying to get PhpStorm to debug it using Xdebug.

When I run PhpStorm it launches the web app in the browser with relevant debugging parameters in the browser.

IDE KEY is matching

ide

xdebug.remote_port is configured correctly. (Later I found that this is wrong, but not erroneous. It should be port 9000)

xdebug.remote_port

But it seems Xdebug never gets to communicate with PhpStorm. PhpStorm keeps listening, and the execution runs completely without stopping at any break-points.

PhpStormPhpStorm

15
1) Does debug works at all (e.g. even in CLI mode / "PHP Script" type of Run/Debug Configuration) ? 2) Is PhpStorm the one who listens on xdebug port (you can use standard netstat or download tcpview from MS website) 3) Have you set up path mappings (Settings | PHP | Servers) -- PhpStorm should ask you to do this when it receives xdebug request? 4) Is PhpStorm is enabled in Firewall on xdebug port (wince it's xdebug who connects to PhpStorm)?LazyOne
@LazyOne (1) debugger not working in "PHP Script" type. It skips the break-point completely. Screenshotlaggingreflex
@LazyOne (2) Yes, PhpStorm is listening, but keeps listening. Even though IDE KEY and port appears to be set correctly. It opens up iexplore when I hit run/debug (with that IDEKEY (for xdebug_SESSION...)). [this is in a different "webapp" RUN/DEBUG configuration.]laggingreflex
@LazyOne (1) it's working in "PHP script" type. Don't know how I concluded otherwise earlier/laggingreflex
xdebug.remote_port is for communicating between xdebug and IDE (xdebug will attempt to connect to this port to establish debug connection). It cannot be port where website is running. These 2 articles should do the job: 1) confluence.jetbrains.com/display/PhpStorm/… 2) confluence.jetbrains.com/display/PhpStorm/…LazyOne

15 Answers

50
votes

These lines are crucial to make it work (in php.ini):

zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
xdebug.remote_autostart = 1 # <-------- THIS
xdebug.remote_enable = 1 # <----------- AND THIS

Without these lines xdebug will never work on phpstorm ;)

37
votes

Try changing the xdebug listen port in your php.ini and your IDE.

Running Mac Yosemite, for me the problem was that I installed with homebrew, following a guide that used php-fpm, which uses port 9000 by default (which conflicts with the xdebug default port)... Changing my xdebug.remote_port to 9001 and changing the xdebug port in phpstorm fixed the problem, though I suspect this issue could happen for anyone in any IDE. I googled for the better part of a day and didn't see this solution (since I believe it's so specific to install method).. but I hope it helps someone.

22
votes

Took me about an hour until I noticed that this button wasn't activated ;)

"Run" -> "Start Listening for PHP Debug Connections"

enter image description here

7
votes

First check for on what port xdebug is working on, you can find it in your php.ini under xdebug.remote_port=9123. As you can see in my case it is set to 9123.
Now open PhpStorm go to php debug, see screenshot: enter image description here

under Xdebug you will find Debug port, make sure that its value is the same as in the php.ini file under xdebug.remote_port (9123 in my case).

Hope it helps

5
votes

For me it was changing the line:

xdebug.remote_host=localhost to xdebug.remote_host=myComputerIP

( Mac user: in terminal run ifconfig to find your ip )

4
votes

If anyone else runs into this issue and is using Vagrant, this is what finally fixed it for me:

xdebug.remote_host=10.0.2.2

That needs to be the IP address of your local machine from inside the Vagrant box, and 10.0.2.2 is the default. If you ssh into your Vagrant box, it will show the IP where you logged in from if you want to confirm.

I know this isn't directly relevant to the specific setup the OP had, but this post shows up in a lot of xdebug / PhpStorm Google searches so hopefully this can help someone else.

4
votes

Could be a Firewall.

Day 572... Still haven't slept or eaten... But I finally found the culprit: Windows Defender!

Basically, I had a firewall blocking JetBrains IDE Support chrome extension from sending data to PhpStorm through the default 127.0.0.1:63342 address.

--- Edit

Day 864... Same issue happened again, this time on Linux... But I finally found the culprit: Ubuntu Firewall!

Seriously, this happened to me again a few months later, using Linux, and it was the firewall again. Disabling the firewall solved it sudo ufw disable - If you care for the firewall and want to keep it enabled, gotta dive in deep on creating some sort of whitelist for it.

3
votes

PHPStorm has a build-in tool in Run > Web Server Debug Validation.

It helped me to solve my problem.

enter image description here

1
votes

I also obtain this error message.
Also was troubles with the php.ini but more subtle.

Try to find and delete a row like this

extension=php_xdebug-...

Consider to look at my answer here for details "Xdebug - command is not available".

1
votes

There was a syntax error in php.ini. There were extra "quotes" and ;colons;.

xdebug.remote_port

1
votes

I was having this same problem while trying to test a Laravel project using XAMPP on Windows in PHPStorm. I have no idea what exactly I was doing wrong, but I did get it working eventually. I followed the step-by-step instructions on the PHPStorm site here.

One thing I think that was not configured right was that there was no interpreter set up in the PHP menu in Settings.

I was also trying a few too many combinations of settings in my php.ini. These were the settings that I have when things were working:

zend_extension = C:\xampp\php\ext\php_xdebug-2.3.2-5.6-vc11.dll //as recommended from the Xdebug site itself 
xdebug.remote_enable=1=
xdebug.profiler_enable=1
xdebug.profiler_output_name = "cachegrind.out.%t-%s"

In my Run/Debug Configurations, I use a PHP Web Application setting, that just starts on the root of the site. (At first, I thought the appended ?XDEBUG_SESSION_START=<xxxxxxx> was a mistake, but it is not). Hopefully that might help if someone else is facing a similar issue.

1
votes

Right click "Console" tab and uncheck "Focus on startup" (as seen in below image) should do the trick enter image description here

0
votes

I had an issue where one project would work and not another one. I tried many different configurations and I tried looking at the logs of xdebug, etc. This fix seems to have resolved my issue:

Try setting your actual ports of xdebug to 9123 instead 9000.

The new version (9) of PHPStorm changed its default xdebug connetion port to 9123 (the PHPSTORM config, not the actual xdebug config), probably for a good reason, since having the PHPSTORM config to the xdebug default 9000 didn't work but having them set to 9123 did work and resolved the issue.

0
votes

I tried any of the suggested tricks and finally I called the script by 127.0.0.1/script.php instead of localhost/script.php and bingo!

0
votes

Based on peteclark3 answer:

I think one of solutions if you have multiple php-fpm versions with xdebug, like php5.6-fpm, php7.1-fpm - make sure only one is running. I had both 5.6 and 7.1 running. Then tried to change on 7.1 to 9001 port. But if I change to 9001 port in PhpStorm, then 5.6 starts not working, because it listens on 9000. So each time you change php version, then probably you would need to change setting in phpStorm. So I think it is better to have only one of php-fpm running and all php-fpm versions can use same port.