Connection with xdebug was not established OSX Docker

Answered

Hi there,

I'm struggling with getting phpstorm connected to xdebug set on docker.

Here's what i see when I php -i inside the container, also this is what I see when i do phpinfo(); I set this variable in xdebug.ini 

So that indicates remote_enable is ON.

But when I try to debug I keep getting

When I click "Validate installation" it goes

And after "Show phpinfo"

100% image is correctly linked in CLI interpreters

Anything that I'm missing? Thanks for any advices!

8 comments
Comment actions Permalink

remote_host set to localhost is wrong. localhost here is the container's address, while you need to connect to the host machine.
Set it to the IP of en0.
If it still doesn't work after, please enable Xdebug remote log and check what's happening there.

0
Comment actions Permalink

Tried many configurations, nothing works. I enabled xdebug remote log, this is what I see there

 

Log opened at 2018-02-05 20:41:12
I: Connecting to configured address/port: php-fpm:9071.
W: Creating socket for 'php-fpm:9071', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2018-02-05 20:41:12

Log opened at 2018-02-05 20:41:58
I: Connecting to configured address/port: 172.18.0.1:9071.
W: Creating socket for '172.18.0.1:9071', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2018-02-05 20:41:58

Log opened at 2018-02-05 20:42:08
I: Connecting to configured address/port: 172.18.0.1:9071.
W: Creating socket for '172.18.0.1:9071', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2018-02-05 20:42:08

Log opened at 2018-02-05 20:42:16
I: Connecting to configured address/port: 172.18.0.1:9071.
W: Creating socket for '172.18.0.1:9071', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2018-02-05 20:42:16

Log opened at 2018-02-05 20:43:27
I: Connecting to configured address/port: 172.20.10.2:9071.
E: Time-out connecting to client (Waited: 200 ms). :-(
Log closed at 2018-02-05 20:43:27

Log opened at 2018-02-05 20:43:37
I: Connecting to configured address/port: 172.20.10.2:9071.
E: Time-out connecting to client (Waited: 200 ms). :-(
Log closed at 2018-02-05 20:43:37

Log opened at 2018-02-05 20:43:42
I: Connecting to configured address/port: 172.20.10.2:9071.
E: Time-out connecting to client (Waited: 200 ms). :-(
Log closed at 2018-02-05 20:43:42

0
Comment actions Permalink

Just to be sure - have you configured PhpStorm to listen to 9071 at Preferences | Languages & Frameworks | PHP | Debug?
Another one - is Listening for incoming connections enabled when you're trying to start a session?

0
Comment actions Permalink

OK, update

When I do `php test.php` inside container it works partially - listens for the connections

but when I just click "Debug" on the file test.php in PHPStorm - I get "Connection with xdebug was not established", same as described above

 

What I did - updated my xdebug.ini

xdebug.remote_host=192.168.1.115
xdebug.remote_connect_back=0
0
Comment actions Permalink

/application/test.php - this is the path inside the container

0
Comment actions Permalink

> but when I just click "Debug" on the file test.php in PHPStorm

Please show a screenshot of the Run/Debug configuration you're using for this file.

> When I do `php test.php` inside container it works partially - listens for the connections

Please consider adding correct mappings at Settings | Language & Frameworks | PHP | Servers.

0
Comment actions Permalink

Run/Debug configuration is empty for this file..

There is nothing to type in in "Interpreter options"

 

Remote debug works now, mapping was the problem, and slight server configuration fixes. Thank you for this one!

0
Comment actions Permalink

On Mac OS X you should use:

xdebug.remote_connect_back = 0
xdebug.remote_host = docker.for.mac.host.internal

Mac has changing internal IPs so you could create a alias, but Xdebug has recognized the problem and offers "docker.for.mac.host.internal" as a solution.

1

Please sign in to leave a comment.