Xdebug cannot connect with IDEA Ultimate
I'm having some trouble getting Xdebug connected to IDEA Ultimate. Apologies if posting here is incorrect!
I have a Vagrant VM deployment server configured:I have deployment mappings set up:
I have PHP configured to use the remote PHP on the Vagrant VM:
I have the CLI Interpreter configured to communicate with the Vagrant VM:
The Xdebug settings are configured on the VM as follows:
And my project paths are set up, too:
Additionally, I've followed the steps for Zero Configuration Debugging -- I opted to use the Bookmarklet method.
After starting the VM, I navigate to the beginning page of my project (localhost:8000), use the "Start Debugging" bookmarklet, set a breakpoint in a file that I know is executed, start IDEA listening for a connection, refresh the page, but Xdebug never successfully connects to IDEA.
This is an excerpt from the Xdebug log:
```
Log opened at 2017-07-20 13:27:06
I: Connecting to configured address/port: localhost:9000.
E: Could not connect to client. :-(
Log closed at 2017-07-20 13:27:06
Log opened at 2017-07-20 13:27:06
I: Connecting to configured address/port: localhost:9000.
E: Could not connect to client. :-(
Log closed at 2017-07-20 13:27:06
```
So, I'm at a loss. I would really appreciate any suggestions or guidance you can provide.
Thanks very much for your time!
Please sign in to leave a comment.
Hello,
Are you able to access host 9000 port from inside Vagrant VM?
Was it forwarded correctly?
Hi Vladimir -- thank you for your help!
If I have port forwarding enabled in the Vagrantfile, IDEA says that port 9000 is busy. Here is the line from the configuration:
when this line is uncommented, the Vagrant VM started, and the 'listen' icon selected I get the following event notification:
Maybe I have something else misconfigured? Thanks again for your time and trouble.
Cheers!
Hi there,
>when this line is uncommented, the Vagrant VM started, and the 'listen' icon selected I get the following event notification:
This config line should definitely be disabled/commented out.
When you forward port like that it means that it exposes guest OS's port to host machine (so that you can send requests from your host to the guest) -- typical example is webserver or mysql (that are run inside VM).
For xdebug it is not needed (at all) as it's other way around -- it's xdebug (guest OS) that connects to the client (IntelliJ/PhpStorm; host OS). If Vagrant is listening on xdebug port then IDE is unable to listen it. So if anything -- it should be other way around forwarding (SSH tunnel?) -- from guest to host.
In fact -- if you are using "xdebug.remote_host = localhost" then you must ensure that SSH tunnel forwards local incoming connections on that TCP 9000 port from guest to host (SSH tunnel: https://confluence.jetbrains.com/display/PhpStorm/Remote+debugging+in+PhpStorm+via+SSH+tunnel).
So -- either ensure that such forwarding is running ... or use proper IP of your host machine (as seen from guest OS -- e.g. check $_SERVER['REMOTE_ADDR'] as an example) for xdebug.remote_host.
In general: https://confluence.jetbrains.com/display/PhpStorm/Debugging+with+PhpStorm
Andriy and Vladimir --
Hey, thank you *very* much for your help! That clears up my issues.
It would be great if there was some link to the SSH tunneling OR the $_SERVER['REMOTE_ADDR'] method somewhere in the IDEA documentation. I may be overlooking it, but I can't seem to find it. Is this something I could open a ticket on?
Again, thanks a bunch for your time and trouble.
Best,
Bridger