View Issue Details

IDProjectCategoryView StatusLast Update
0001614XdebugRemote Debuggingpublic2019-02-19 16:21
ReporterluchuanbakerAssigned Toderick 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
PlatformApache24 + php + xdebug + IdeaOSWindowsOS Version10
Product Version2.6.1 
Target VersionFixed in Version 
Summary0001614: Remote address localhost is ::1 or 127.0.0.1
DescriptionWhen debugging with http://localhost, xdebug can not deal with localhost properly, as the log:
Remote address found, connecting to ::1:9000
Time-out connecting to client (Waited: 200 ms). :-(

Is there a config that can convert localhost to 127.0.0.1 as IPv4, not ::1 as IPv6, because idea create the debug server by IPv4 that is 127.0.0.1... so the error happens.....

The problem can be resolved easily by just replacing http://localhost with http://127.0.0.1..... but I hope there is a config....
TagsNo tags attached.
Operating System
PHP Version7.1.25-7.1.29

Activities

derick

2019-01-29 14:52

administrator   ~0004850

Could you show the whole section of the log that does the connection? From the part where it says:

Log opened at 2019-01-29 14:50:58

to where it says:

Log closed at 2019-01-29 14:50:58

And please don't leave out anything.

Secondly, can you provide the *raw* HTTP request and response headers, with a tool such as Chrome's or Firefox's dev tools?

luchuanbaker

2019-01-30 02:10

reporter   ~0004853

When visit http://localhost/, xdebug can not work properly, the log is:
Log opened at 2019-01-30 01:55:51
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to ::1:9000.
E: Time-out connecting to client (Waited: 200 ms). :-(
Log closed at 2019-01-30 01:55:51

When visit http://127.0.0.1/, xdebug work properly, and the log is:
Log opened at 2019-01-30 01:59:03
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 127.0.0.1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_...
extra log..

The different is ip, when visit localhost the ip is ipv6 while 127.0.0.1 is ipv4

The php plugin of idea binds socket using ipV4, when I run `netstat -nao | find "9000"` in cmd:
C:\Users\clu>netstat -nao | find "9000"
TCP 0.0.0.0:9000 0.0.0.0:0 LISTENING 10964

So if xdebug connect to ::1:9000 (IPv6), it can not connect successfully, but is connect to 127.0.0.1:9000 (IPv4), it is OK.

-----------------------------------------------------
I have tried to change the config in php.ini:
from
xdebug.remote_host = localhost
to
xdebug.remote_host = 127.0.0.1

but it has no effect...
so, I just need a config for xdebug as follows in php.ini
xdebug.prefer_ipv4_stack = true
then it can connect to the debug server by 127.0.0.1:9000 when I visit http://localhost.

or make the config `xdebug.remote_host = 127.0.0.1` become effective

derick

2019-02-01 15:21

administrator   ~0004858

You wrote:

> I have tried to change the config in php.ini:
> from
> xdebug.remote_host = localhost
> to
> xdebug.remote_host = 127.0.0.1
>
> but it has no effect...

That makes sense, as this setting is ignored when you have xdebug.remote_connect_back turned on. So turning off remote_connect_back should solve this problem.

Xdebug uses the Operating System's mechanisms (getaddrinfo()) to convert and Xdebug *does* look at all returned matches for a specific *name*. On correct setups, that would include the IPv4 and IPv6 variants.

However, in:

> I: Remote address found, connecting to ::1:9000.

We see that your browser doesn't send over localhost in the HTTP headers, but instead uses "::1" which means that Xdebug can't do its own name resolving from "localhost" to both IPv4 and IPv6 variants.

In any case, turning off xdebug.remote_connect_back (setting it to =0) should do the trick for you.

derick

2019-02-12 19:24

administrator   ~0004900

is this now resolved for you?

luchuanbaker

2019-02-15 04:25

reporter   ~0004911

yes, thanks...

derick

2019-02-19 16:21

administrator   ~0004915

Thanks for letting me know. I'll close this issue then.

Issue History

Date Modified Username Field Change
2019-01-29 13:12 luchuanbaker New Issue
2019-01-29 14:52 derick Note Added: 0004850
2019-01-29 14:52 derick Assigned To => derick
2019-01-29 14:52 derick Status new => feedback
2019-01-30 02:10 luchuanbaker Note Added: 0004853
2019-01-30 02:10 luchuanbaker Status feedback => assigned
2019-02-01 15:21 derick Note Added: 0004858
2019-02-01 15:21 derick Status assigned => feedback
2019-02-12 19:24 derick Note Added: 0004900
2019-02-15 04:25 luchuanbaker Note Added: 0004911
2019-02-15 04:25 luchuanbaker Status feedback => assigned
2019-02-19 16:21 derick Status assigned => resolved
2019-02-19 16:21 derick Resolution open => no change required
2019-02-19 16:21 derick Note Added: 0004915