Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phpstorm + xdebug : Remote host is configured as "localhost" despite server host is probably not local

I was following this instruction to validate my debugger configuration on Web Server. I uses a remote server whose FTP connection has been tested, but I get this warning message saying

Remote host is configured as 'localhost' despite server host is probably not local

enter image description here

My first question is: what does "remote host" and "server host" refer to respectively?

I know remote host is the setting xdebug.remote_host, and according to the xdebug documentation, it is "the host where the debug client is running".

This makes me confused: Isn't the debug client the IDE I am running on my local machine?

If yes, then shouldn't "the host where the debug client is running" be my local machines's IP address? If yes again, should I configure xdebug.remote_host to be my IP?

I tried setting it to my IP, the warning message does't show but it doesn't feel right because later I tried it with a random IP the message also doesn't show.

Secondly, the xdebug documentation also says that this xdebug.remote_host setting will be ignored if xdebug.remote_connect_back is enabled." Although not quite sure what this setting does, I set it to be "On", as the picture shows: enter image description here

I was hoping this will eliminate the warning message, but it is still there. So how do I get rid of this message?

like image 699
shenkwen Avatar asked Mar 15 '16 03:03

shenkwen


People also ask

Why is Xdebug not working?

Xdebug cannot connect to PhpStorm This means that Xdebug tries to connect to the host and can't make the connection. To fix the issue, set xdebug. remote_connect_back=0 ( xdebug. discover_client_host=false for Xdebug 3) and make sure that xdebug.

How do I know if Xdebug is running?

Verify that Xdebug is properly running by checking again with phpinfo() or php -v as explained above. Note that 9003 is the default port. If this port is used by another service on your system, change it to an unused port. After adding these settings, restart your webserver again.

How do I debug Xdebug?

Press F5 to start the debugger. Click the new XDebug Helper extension and click the Debug option. Finally, refresh the page in the browser to let VSCode react and start the debugging process.


1 Answers

In my case, I had several apache virtual hosts setup for different projects. I was able to access projects via different urls, like : http://projectname1, http://anotherproject2 .

I was getting that same error in PhpStorm while doing xdebug validation:

Remote host is configured as “localhost” despite server host is probably not local

Problem was fixed, once in php.ini xdebug.remote_host matched the URL of the project I was debugging. So, if I was debugging http://project1, I would have this in php.ini:

xdebug.remote_host="project1"

Having values as 127.0.0.1, or localhost didn't fix it.

Hope it helps someone.

like image 184
Muhammed Avatar answered Oct 19 '22 23:10

Muhammed