{"id":697,"date":"2021-04-30T13:56:31","date_gmt":"2021-04-30T12:56:31","guid":{"rendered":"http:\/\/blog.chen-hongyi.com\/?p=697"},"modified":"2021-04-30T13:56:31","modified_gmt":"2021-04-30T12:56:31","slug":"xdebug-error-message-xdebug-step-debug-could-not-connect-to-debugging-client-tried-host-docker-internal9003-in-docker","status":"publish","type":"post","link":"https:\/\/chen-hongyi.com\/?p=697","title":{"rendered":"xdebug error message &#8220;Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003&#8221;  in docker"},"content":{"rendered":"\n<p>I got this error message in docker log output: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Xdebug: &#91;Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003<\/code><\/pre>\n\n\n\n<p>I could not connect xdebug in phpstorm. I checked port config, it is correct. But I am not sure, where the message &#8220;host.docker.internal&#8221; come from. Until I found here: <\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/docker\/for-linux\/issues\/264#issuecomment-381437057\">https:\/\/github.com\/docker\/for-linux\/issues\/264#issuecomment-381437057<\/a><\/p>\n\n\n\n<p>and <\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/31324981\/how-to-access-host-port-from-docker-container\/43541732#43541732\">https:\/\/stackoverflow.com\/questions\/31324981\/how-to-access-host-port-from-docker-container\/43541732#43541732<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>So I add following config in my compose.yml for web server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...\n extra_hosts:\n      - \"host.docker.internal:192.168.2.193\"\n...\n<\/code><\/pre>\n\n\n\n<p>After rebuild the image, you can check your hosts file in container. It has a new line in \/etc\/hosts, like <\/p>\n\n\n\n<p>192.168.2.193 host.docker.internal<\/p>\n\n\n\n<p>This is IP from my host, on that is runing phpstorm with listen to port 9003. And it works. Of course you must install xdebug and enbalbe it first. And check your php.ini the section:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;xdebug]\nxdebug.mode=coverage\nxdebug.client_host=localhost\nxdebug.client_port=9003\nxdebug.start_with_request=yes<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I got this error message in docker log o &hellip; <a href=\"https:\/\/chen-hongyi.com\/?p=697\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-697","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts\/697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=697"}],"version-history":[{"count":1,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts\/697\/revisions"}],"predecessor-version":[{"id":698,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=\/wp\/v2\/posts\/697\/revisions\/698"}],"wp:attachment":[{"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chen-hongyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}