Remote Debugging with XDebug

I can't get XDebug to work via a Remote Server.

I've tried the Zero-configuration tutorial several times and have set the xdebug.remote_host to my local ip.

I've also setup port forwarding for my router, turned off firewall, but still no dice.

Any help would be apprecaited.

xdebug

xdebug support enabled
Version 2.2.6
IDE Key PHPSTORM

Supported protocols Revision
DBGp - Common DeBuGger Protocol $Revision: 1.145 $

Directive Local Value Master Value
xdebug.auto_trace Off Off
xdebug.cli_color 0 0
xdebug.collect_assignments Off Off
xdebug.collect_includes On On
xdebug.collect_params 0 0
xdebug.collect_return Off Off
xdebug.collect_vars Off Off
xdebug.coverage_enable On On
xdebug.default_enable On On
xdebug.dump.COOKIE no value no value
xdebug.dump.ENV no value no value
xdebug.dump.FILES no value no value
xdebug.dump.GET no value no value
xdebug.dump.POST no value no value
xdebug.dump.REQUEST no value no value
xdebug.dump.SERVER no value no value
xdebug.dump.SESSION no value no value
xdebug.dump_globals On On
xdebug.dump_once On On
xdebug.dump_undefined Off Off
xdebug.extended_info On On
xdebug.file_link_format no value no value
xdebug.idekey no value no value
xdebug.max_nesting_level 100 100
xdebug.overload_var_dump On On
xdebug.profiler_aggregate Off Off
xdebug.profiler_append Off Off
xdebug.profiler_enable Off Off
xdebug.profiler_enable_trigger Off Off
xdebug.profiler_output_dir /tmp /tmp
xdebug.profiler_output_name cachegrind.out.%p cachegrind.out.%p
xdebug.remote_autostart Off Off
xdebug.remote_connect_back Off Off
xdebug.remote_cookie_expire_time 3600 3600
xdebug.remote_enable On On
xdebug.remote_handler dbgp dbgp
xdebug.remote_host 55.55.555.55 <my public ip> 55.55.555.55 <my public ip>
xdebug.remote_log no value no value
xdebug.remote_mode req req
xdebug.remote_port 9000 9000
xdebug.scream Off Off
xdebug.show_exception_trace Off Off
xdebug.show_local_vars Off Off
xdebug.show_mem_delta Off Off
xdebug.trace_enable_trigger Off Off
xdebug.trace_format 0 0
xdebug.trace_options 0 0
xdebug.trace_output_dir /tmp /tmp
xdebug.trace_output_name trace.%c trace.%c
xdebug.var_display_max_children 128 128
xdebug.var_display_max_data 512 512
xdebug.var_display_max_depth 3 3
16 comments
Comment actions Permalink

Hi there,

So .. what xdebug logs says?

0
Comment actions Permalink

Nothing is being written to them.

I'm assuming I set them up by assigning a writeable file to "xdebug.remote_log".

Thanks

0
Comment actions Permalink
I'm assuming I set them up by assigning a writeable file to "xdebug.remote_log".

Correct.

0
Comment actions Permalink

I've done that and still nothing is being written. Should the change be immediate or will I need to contact my hosting company?

0
Comment actions Permalink

Hosting company? You having xdebug installed and running on production server?

In any case: it all depends on configuration:
1) where you write those settings (what files);
2) how they loaded by PHP;
3) how PHP is loaded/executed by web server.

In most cases such settings are:
* stored in php.ini (or one of the files loaded once by PHP on startup); sometimes in local (user) php.ini or .htaccess (they usually re-read on each request or some small interval)
* got read on PHP process startup (if it's not FastCGI but Apache module .. then on Apache startup only).

Your best choice (covers all setups) would be to restart web server so that it re-reads all config files for all modules.

0
Comment actions Permalink

I'm looking to run XDebug during development on a remote server. My work needs require that others have access to completed admin portions of the site while development is in progress.

I have a user level php.ini file in my main public_html directory.

I'll have to check with my hosting company to see if a restart is possible.

Thanks,

0
Comment actions Permalink

Just check "xdebug" section of phpinfo() output (like the one in opening comment here) -- if config file was read then the path to log file will be listed there.

If it's there but still nothing in logs, then:

  • access rights to log file
  • check the path to it
  • xdebug does not see "session start" command (be it via cookie or GET/POST parameter) -- use xdebug.remote_autostart = 1 to have xdebug attempting to debug every single request (yes, may not be convenient, but at least you will see that it's working)
  • if there is something -- check IP and port - make sure it's yours
  • if still nothing -- make sure that PhpStorm is the one that listens (correct) xdebug port -- use netstat or similar app that can tell which program listens which port
  • if all good, but xdebug says "unable to connect" -- check your firewall/router. If you think it's OK -- enable "phone handle" icon in PhpStorm and attempt to connect from remote computer via telnet (or similar app)
0
Comment actions Permalink

Oops,

Looks like I was missing a directory in my path.

Now the log file essentially gives me this repeated

Log opened at 2014-11-18 15:39:29
I: Connecting to configured address/port: 55.55.555.55:9000.
E: Time-out connecting to client. :-(
Log closed at 2014-11-18 15:39:29

0
Comment actions Permalink

Now try what I have suggested above:

  • make sure that PhpStorm is the one that listens (correct) xdebug port -- use netstat or similar app that can tell which program listens which port
  • check your firewall/router. If you think it's OK -- enable "phone  handle" icon in PhpStorm and attempt to connect from remote computer via  telnet (or similar app)
  • if unable to connect from your server -- try connecting vi atelnet from another computer in your LAN.
  • If connected -- check router / corporate firewall; If all good here -- check firewall on actual server -- it may block outgoing connections.
0
Comment actions Permalink

Thanks for the help,

Turns out it was a problem with the server blocking the port.

0
Comment actions Permalink

Hello, i have the same problem. I attempted to do this things that you adviced:

  • check your firewall/router. If you think it's OK -- enable "phone  handle" icon in PhpStorm and attempt to connect from remote computer via  telnet (or similar app)
  • if unable to connect from your server -- try connecting vi atelnet from another computer in your LAN.

I try to connect to my host with Phpstorm via telnet and get this:

talanin-vm ~ # telnet 192.168.191.14 9089
Trying 192.168.191.14...
telnet: Unable to connect to remote host: Connection timed out

and from another servers...

root@analyticApiApp1:~# telnet 192.168.191.14 9089
Trying 192.168.191.14...
telnet: Unable to connect to remote host: Connection timed out

What does this means? On the host 192.168.191.14 with Windows 7 in the firewall rules are added to the 9089 port over TCP. Maybe worth a try to add a firewall exception over DBGp? What else can i do?

0
Comment actions Permalink

Have you checked that
1) PhpStorm is listening on that port?
2) It's PhpStorm and not another app on that port?

Maybe worth a try to add a firewall exception over DBGp?

What it that?

0
Comment actions Permalink

I get this when running debug:

C:\Users\TALANIN>netstat -an | find ":9089"
  TCP    0.0.0.0:9089           0.0.0.0:0              LISTENING

and when debugging is off:

C:\Users\TALANIN>netstat -an | find ":9089"

This means that other apps can't use this port, isn't it?

Maybe worth a try to add a firewall exception over DBGp?

What it that?

I made a mistake here. In the firewall can't add a custom protocol such as DBGp

0
Comment actions Permalink
This means that other apps can't use this port, isn't it?

Yes.

P.S.
You can use "-b" param to see process name associated with connection (will not work with "find"  as it printed on separate line).

If you can (if you have not done it yet) -- see if local (on the same computer) debug is working (that's, of course, if you have local PHP).

I'm not sure what else could be wrong here -- since I'm not there and not familiar with situation. But if you are not able to connect to PhpStorm while listening for debug connections ("phone handle" icon is activated) then it could be:

  • your firewall (be it local (your PC) or somewhere on network (router))
  • server firewall (your linux distro may have such security settings that does not allow "out of blue" outgoing connections) -- could be selinux or iptables (sorry, not a Linux person here)
  • if you are connecting from within VM (e.g. vagrant) -- check their firewall / rules -- it may also limit outgoing connections.
  • wrong IP:port


If nothing -- see if you can debug via SSH tunnel. For example:

0
Comment actions Permalink

If you can (if you have not done it yet) -- see if local (on the same computer) debug is working (that's, of course, if you have local PHP)

Yes, i checked that. On other computers debugging works fine with the same settings in local network (Windows 7, Linux)

  • server firewall (your linux distro may have such security settings that does not allow "out of blue" outgoing connections) -- could be selinux or iptables (sorry, not a Linux person here)

I don't have firewall on computer under linux.

0
Comment actions Permalink
If nothing -- see if you can debug via SSH tunnel. For example:

It has helped me. Solved the problem that the debug through SSH tunnel. Thanks a lot!

0

Please sign in to leave a comment.