Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support: XDEBUG not working in WSL2 environment (docker-ce inside WSL2) with phpstorm on windows #4242

Closed
1 task done
mvinaj opened this issue Sep 30, 2022 · 24 comments
Closed
1 task done

Comments

@mvinaj
Copy link

mvinaj commented Sep 30, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Run a Diagnostic and Paste Link Here

DDEV version:  ITEM             VALUE
 DDEV version     v1.21.1
 architecture     amd64
 db               drud/ddev-dbserver-mariadb-10.4:v1.20.0
 dba              phpmyadmin:5
 ddev-ssh-agent   drud/ddev-ssh-agent:v1.20.0
 docker           20.10.18
 docker-compose   v2.9.0
 mutagen          0.15.1
 os               linux
 router           drud/ddev-router:v1.20.0
 web              drud/ddev-webserver:20220808_yarn_crash
PROXY settings: HTTP_PROXY='' HTTPS_PROXY='' http_proxy='' NO_PROXY=''
======= DDEV global info =========
Global configuration:
instrumentation-opt-in=false
omit-containers=[]
mutagen-enabled=false
nfs-mount-enabled=false
router-bind-all-interfaces=false
internet-detection-timeout-ms=3000
disable-http2=false
use-letsencrypt=false
letsencrypt-email=
table-style=default
simple-formatting=false
auto-restart-containers=false
use-hardened-images=false
fail-on-hook-fail=false
required-docker-compose-version=
use-docker-compose-from-path=false
no-bind-mounts=false

======= DOCKER info =========
docker location: -rwxr-xr-x 1 root root 50718336 Sep  9 01:09 /usr/bin/docker
docker version:
Client: Docker Engine - Community
 Version:           20.10.18
 API version:       1.41
 Go version:        go1.18.6
 Git commit:        b40c2f6
 Built:             Thu Sep  8 23:11:45 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.18
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.6
  Git commit:       e42327a
  Built:            Thu Sep  8 23:09:37 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.8
  GitCommit:        9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
DOCKER_DEFAULT_PLATFORM=notset

Expected Behavior

xdebug works out of the box If I start my ddev project and activate xdebug.

Actual Behavior

i get a error

ddev logs show :
WARNING: [pool www] child 2706 said into stderr: "NOTICE: PHP message: Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-("

in the container:

PING host.docker.internal (172.17.0.1) 56(84) bytes of data.

Trying 172.17.0.1...
telnet: Unable to connect to remote host: Connection refused

/etc/hosts

172.17.0.1 host.docker.internal

Steps To Reproduce

docker running in WSL
phpstorm on windows
ddev xdebug on
enable lisener in phpstorm

Anything else?

image

@rfay
Copy link
Member

rfay commented Sep 30, 2022

Hi @mvinaj -

  1. Are you running Docker Desktop, or do you have docker-ce installed in WSL2?
  2. Where are you running PhpStorm? On Windows or inside WSL2?
  3. Have you enabled PhpStorm's listen button? You'll certainly get this if you haven't

Could you please go more carefully through the troubleshooting steps? For example, you should have been doing telnet host.docker.internal 9003, not just telnet host.docker.internal.

@mvinaj
Copy link
Author

mvinaj commented Sep 30, 2022

Hi @rfay

  1. I have docker-ce installed in wsl
  2. Phpstorm is running on windows
    3 yes he is enabled

Could you please go more carefully through the troubleshooting steps?
I tried:
-changed the Port to 11101

  • checked the php info
  • Set to ipv4

telnet host.docker.internal 9003, not just telnet host.docker.internal:

Iam sorry i missed to copy the full command

@rfay
Copy link
Member

rfay commented Sep 30, 2022

Please don't change the port. Please remove any custom configuration.

I imagine your problem is

The solution there may work for you, #3772 (comment)

Also, please make sure you have done the normal troubleshooting things:

  • Temporarily turn off VPN/Firewall/virus checker/etc
  • Reboot

@rfay
Copy link
Member

rfay commented Oct 4, 2022

The temporary solution to this problem is in

Closing this in favor of the other issue. Please let me know how the solution works for you.

@rfay rfay closed this as completed Oct 4, 2022
@mvinaj
Copy link
Author

mvinaj commented Oct 5, 2022

@rfay the solution didnt work for me still the same erros

@rfay
Copy link
Member

rfay commented Oct 5, 2022

If it's still showing "host.docker.internal" in the error, then you didn't set up the php config with the proper IP address.

Please reply in the open issue, and say exactly what you did and exactly what the results were. You can say that you're coming from this issue. But note that if it still is trying to connect to host.docker.internal, I don't think you changed the php config properly.

@mvinaj
Copy link
Author

mvinaj commented Oct 6, 2022

if it's still showing "host.docker.internal": "NOTICE: PHP message: Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: 172.20.16.1:9003 (through xdebug.client_host/xdebug.client_port) :-("

please reply in the open issue, and say exactly what you did and exactly: i will

Thanks for all your help

@rfay
Copy link
Member

rfay commented Oct 6, 2022

I'd be happy to do a screenshare with you to see if we can sort this out. I'm in US MT (UTC-6). Let me know what would be a good time for you.

In the meantime, please carefully go through the troubleshooting steps using the new IP address. But I'm surprised to see an IP like 172.20.16 - that's what you found in your WSL2 distro's /etc/resolv.conf? Maybe you can paste the /etc/resolv.conf here. (That IP addr looks like what you might find inside the container, not in the WSL2 distro)

@rfay rfay changed the title XDEBUG not working in WSL2 environment with phpstorm on windows Support: XDEBUG not working in WSL2 environment (docker-ce inside WSL2) with phpstorm on windows Oct 6, 2022
@rfay rfay reopened this Oct 6, 2022
@mvinaj
Copy link
Author

mvinaj commented Oct 7, 2022

/etc/resolv.conf:

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.20.112.1

in
/etc/resolv.conf with ddev ssh

nameserver 127.0.0.11
options: ndots:0

@rfay
Copy link
Member

rfay commented Oct 7, 2022

Yes, but in your testing you were not using 172.20.112.1, you were using 172.20.16.1, please try it with the value from your /etc/resolv.conf, which is 172.20.16.1 - put that in your .ddev/php/xdebug.ini and ddev restart:

xdebug.client_host=172.20.112.1

@rfay
Copy link
Member

rfay commented Oct 7, 2022

And, of course, try the troubleshooting steps in the doc, using 172.20.112.1 instead of host.docker.internal

@mvinaj
Copy link
Author

mvinaj commented Oct 7, 2022

Yes, but in your testing you were not using 172.20.112.1, you were using 172.20.16.1: i think i need to disbale the automatic generation of this file.

loading the .ini

Using custom PHP configuration: [/home///.ddev/php/xdebug.ini]

ddev logs:
[07-Oct-2022 13:08:50] WARNING: [pool www] child 2700 said into stderr: "NOTICE: PHP message: Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: 172.20.112.1:9003 (through xdebug.client_host/xdebug.client_port) :-("

in the container:

telnet 172.20.112.1 9003
Trying 172.20.112.1...
telnet: Unable to connect to remote host: Connection timed out

@rfay
Copy link
Member

rfay commented Oct 7, 2022

Please go through the troubleshooting steps. Have you enabled listen in PhpStorm? Please do it step by step. And please make sure you have disabled your firewall/VPN/Virus checker.

@rfay
Copy link
Member

rfay commented Oct 7, 2022

As I said above, I'm happy to do a screenshare call with you to sort this out. WSL2 is complicated in terms of networking, and different situations may result in different learning.

@mvinaj
Copy link
Author

mvinaj commented Oct 11, 2022

i think its a good idea to do a screenshare. iam from germany so we only need to find the right time

@rfay
Copy link
Member

rfay commented Oct 11, 2022

Hi @mvinaj - I can do today (Tuesday) between now (2:17pm your time) and 4pm your time, at 4:30pm your time, or tomorrow (Wed) between 3pm and 5pm your time. Let me know. It would be easier to schedule this more interactively in DDEV discord

rfay added a commit to rfay/ddev that referenced this issue Oct 11, 2022
@rfay
Copy link
Member

rfay commented Oct 12, 2022

Thanks for taking the time to look at this today. It seems that your employer has locked down your computer in a way that WSL2 can't make a connection to Windows (where you have PhpStorm running).

Our ideas for workarounds for you:

Your IT department also seems to have DNS rebinding prohibited, which is why you have to edit the windows hosts file. This would probably also be resolved by running your browser inside wsl2. https://ddev.readthedocs.io/en/latest/users/basics/troubleshooting/#dns-rebinding-prohibited

Hoping something works! Closing this for now, but happy to follow up any time.

@rfay rfay closed this as completed Oct 12, 2022
rfay added a commit to rfay/ddev that referenced this issue Oct 13, 2022
rfay added a commit to rfay/ddev that referenced this issue Oct 15, 2022
rfay added a commit to rfay/ddev that referenced this issue Oct 20, 2022
rfay added a commit that referenced this issue Oct 24, 2022
…ixes #4242, fixes #3772, fixes #3813 (#4252)

* Make host.docker.internal work with docker-installed-inside, fixes #4242, fixes #3772
* For WSL2 with Windows browser, docker-ce, parse /etc/resolv.conf
* Require Docker 20.10 so we can use extra_hosts always
* Add xdebug-ide-location to global config [skip ci]
@mvinaj
Copy link
Author

mvinaj commented Nov 4, 2022

Hi @rfay,

sorry for the late response. I found the solution for my setup. I needed to update my Windows Defender Firewall after i enabled both Phpstorms. It worked for me.

image

@rfay
Copy link
Member

rfay commented Nov 4, 2022

I'm glad you got it solved. Firewall is the first thing on the troubleshooting list :) Some companies just make it too hard, don't they.

@ChristianAdamski
Copy link

Just for the log: ran into the same issue. Firewall setting solved it. Thanks @mvinaj

@funder7

This comment was marked as off-topic.

@rfay

This comment was marked as off-topic.

@funder7

This comment was marked as off-topic.

@rfay
Copy link
Member

rfay commented Oct 11, 2023

Yes, please comment in appropriate places. Otherwise you just create confusion. Commenting in unrelated repositories with out-of-date suggestions is not helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants