question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot connect to xdebug - `Connection to the debugger has been closed`

See original GitHub issue

I’m trying to connect to xdebug on a remote VM, but it just fails instantly with “Connection to the debugger has been closed”. I created github repo with a Vagrant VM which reproduces this issue. Once up and running, the VM is reachable at 33.33.33.10 and has xdebug loaded (it appears in phpinfo output ). I have also checked that xdebug.ini is parsed.

Logging doesn’t help much:

- [Info] {Fri 19 2013 11:59:14} Connection to the debugger has been closed

Looking through the source code, it seems this message is shown when a socket is closed, but I don’t know where to go from here.

vdebug settings:

g:vdebug_options      
{'debug_file': 'vdebug_log',
'debug_file_level': 2,
'watch_window_style': 'expanded',
'marker_default': '*',
'continuous_mode': 0,
'ide_key': '',
'break_on_open': 1,
'on_close': 'detach',
'path_maps': {'/var/www': 'C:\code\xdebug-test'},
'marker_closed_tree': '+',
'timeout': 20,
'port': 9000,
'marker_open_tree': '-',
'debug_window_level': 1,
'server': '33.33.33.10'}

Also, here’s some output from Apache’s access.log:

33.33.33.1 - - [19/Apr/2013:12:26:11 +0100] "GET /debug_me.php HTTP/1.1" 200 314 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0"

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:41

github_iconTop GitHub Comments

1reaction
nathanielkscommented, Oct 1, 2016

@Iazel you’re a lifesaver. My understanding of remote_port was the same as yours before. That totally makes sense now!

0reactions
iazelcommented, Aug 1, 2016

Hello guys! I’m trying to use docker and this error popup. My current vdebug_options:

let g:vdebug_options = {
      \ 'port': '9001',
      \ "server": '',
      \ 'ide_key': '', 
      \ 'path_maps': {'/var/www/html': expand('<sfile>:h:p')}, 
      \ 'debug_file': '/tmp/vdebug.log', 
      \ 'debug_file_level': 2 
      \ }

However in the log there’s no useful information, only this:

- [Info] {lun 01 2016 12:22:53} Connection to the debugger has been closed

My Dockerfile configuration:

FROM php:7-fpm
RUN yes | pecl install xdebug
ADD ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini

The xdebug.ini:

xdebug.remote_enable=1;
xdebug.remote_port=9001;
xdebug.remote_connect_back=1;
xdebug.max_nesting_level=200
xdebug.idekey=""
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so

This is the relevant bit of the docker-compose.yml

php:
    build: ./docker/php/
    expose:
        - 9000
    ports:
        - '9001:9001'
    links:
        - mysql
    volumes_from:
        - app

Any ideas?

Solved

Ok, it seems I wasn’t understanding what remote_port means. I thought it was the port where the debugger was listening to (like node --debug), but It turns out is the other way around and it should be the port on the local machine, the one from which we initiate the debugging! Removing the port bind on 9001 has done the trick, and even more, using docker we can use the default 9000 port 😃

Corret docker-compose.yml:

php:
    build: ./docker/php/
    expose:
        - 9000 # needed by nginx + fpm
    links:
        - mysql
    volumes_from:
        - app

And the xdebug.ini can be shortened to

xdebug.remote_enable=1;
xdebug.remote_connect_back=1;
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so
Read more comments on GitHub >

github_iconTop Results From Across the Web

php - Xdebug unable to connect to client, where do I start ...
A solution that is possible in intranets and VPNs is to configure xdebug to connect to port 9000 of the local machine but,...
Read more >
Troubleshooting common PHP debugging issues | PhpStorm ...
When the debugger cannot connect or refuses the connection, check the following: Make sure Xdebug or Zend Debugger are configured to connect ......
Read more >
Documentation » Description of errors - Xdebug
Occurs when Xdebug is trying to connect to a debuging client to start a debugging session. The debugger could not make a connection...
Read more >
failed to launch debug adapter cannot connect to runtime ...
While you wait for the fix, there are multiple reasons for this error to show up but the most probably is because the...
Read more >
The Visual Studio Remote Debugger service on the target ...
This error means that the remote debugger service is running under a user account that cannot authenticate when it tries to connect to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found