1

I'm using PhpStorm and having a problem with Docker and Xdebug. When I check the logs of xdebug in /tmp/xdebug.log, it shows these errors:

[27] I: Connecting to configured address/port: host.docker.internal:9001.
[27] W: Creating socket for 'host.docker.internal:9001', getaddrinfo: Invalid argument.
[27] E: Could not connect to client. :-(
LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • 1
    What is your host OS (where Docker/PhpStorm is running)? As far as I can interpret that message it should mean that your container OS (docker image) is unable to resolve `host.docker.internal` host name. That name is available for docker running on Windows and Mac only. For Linux hosts you need to use some workarounds. https://stackoverflow.com/q/22944631/783119 and https://github.com/docker/for-linux/issues/264 – LazyOne Jul 29 '20 at 10:22
  • @LazyOne I'm using ubuntu to run PhpStorm and docker – Gauss Shiroemon Madeon Jul 30 '20 at 02:58
  • That `host.docker.internal` host name is not available on Ubuntu. You need to use workarounds to find out the IP address of the host and pass it to Xdebug config. Check those 2 links for that; also go through [xdebug + docker tags](https://stackoverflow.com/questions/tagged/xdebug+docker) here on SO; they often have docker compose file content or similar where you may see how they are going that – LazyOne Jul 30 '20 at 08:13
  • @LazyOne Thank you, I fixed the host.docker.internal issue, then when I check the error log, it shows " poll success, but error: Operation now in progress (29). [18] E: Could not connect to client. :-(". Does it mean the IP address is wrong or smt ? – Gauss Shiroemon Madeon Jul 31 '20 at 02:20
  • *"Does it mean the IP address is wrong or smt"* Yes. Few possible reasons: 1) You have detected and used the wrong IP address; 2) Firewall on your Host OS; 3) IDE is not listening on 9001 port at that moment (e.g. for PhpStorm make sure that you have clicked "Debug" button (if you are doing via Run/Debug Configurations approach) or that the "phone handle" icon is green (which indicates that IDE is listening for incoming debug connections without active Debug yet). 4) Maybe that port is busy by something else. Use `netstat` or alike and confirm it's PhpStorm listening. – LazyOne Jul 31 '20 at 07:46
  • @Lazy One Thank you, I think now it can be connected. The message "Connected to client. :-)" is showed. I want to confirm that does the port in XDEBUG_CONFIG in docker_composer.yml need to be similar to the port in the Settings/PHP/Debug and Settings/PHP/Servers? Now I'm setting the port in docker_composer.yml is 80 and in Settings is 9001. This message is displayed. Although I marked the breakpoint, nothing is showed in Debugbar except "Waiting ... 'PHPSTORM'" – Gauss Shiroemon Madeon Jul 31 '20 at 09:42
  • Xdebug port is a completely DIFFERENT thing to web site port. Xdebug port must be the same in both php.ini and Xdebug section of PhpStorm. Port `80` has NOTHING to do with Xdebug, at all. 1) https://blog.jetbrains.com/phpstorm/2018/08/quickstart-with-docker-in-phpstorm/ 2) https://www.jetbrains.com/phpstorm/documentation/debugging/ 3) https://www.jetbrains.com/help/phpstorm/debugging-with-phpstorm-ultimate-guide.html – LazyOne Jul 31 '20 at 10:53

0 Answers0