Waiting For Connection (netbeans-xdebug) MAMP OS X - php

Preamble
After many hours, I have been unable to get NetBeans to connect to xdebug. Some months ago, after upgrading from an old version of MAMP to MAMP PRO, debugging worked flawlessly. A week ago it started getting flakey. It would appear to connect but would not stop at the breakpoints. Restarting NetBeans (v7.0.1) and apache sometimes got it working for a short time.
I really needed it fixed so I installed the latest version of MAMP PRO (2.1.2). Now I get the Waiting For Connection message forever.
Testing I have done
While the Waiting For Connection message is there with the moving bar, I look to see if it’s listening. It is...
# lsof -i -n -P |grep 9001
java 6496 tim 230u IPv6 0xffffff80239d8190 0t0 TCP *:9001 (LISTEN)
In NetBeans php config I have the interpreter set to:
/Applications/MAMP/bin/php/php5.4.10/bin/php
Executing the following:
# /Applications/MAMP/bin/php/php5.4.10/bin/php -i | grep xdebug
tells me that xdebug is running as does phpinfo()
I have (many times) confirmed that I have the port number the same everywhere. I have tried port 9000 and 9001.
Doing a tail on xdebug.log then initiating a session from the browser without starting a debug session in NetBeans produces:
I: Connecting to configured address/port: localhost:9001.
E: Could not connect to client. :-(
With the waiting for connection message and initiating a session from the browser, I get this in the log:
: Connecting to configured address/port: localhost:9001.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Users/tim/MAMPSites/facts.tvd.us/htdocs/sendfile/tim.php" language="PHP" protocol_version="1.0" appid="7279" idekey="netbeans-xdebug"><engine version="2.2.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2012 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
My php.ini file has the following:
[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.3.20/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9001
xdebug.idekey="netbeans-xdebug"
Update
I just noticed that the lsof command above shows NetBeans listening on ipV6. Forcing java (NetBeans) to use ipV4 does not help.
launchctl setenv JAVA_TOOL_OPTIONS -Djava.net.preferIPv4Stack=true
I found a post that suggested a test to confirm xdebug is working correctly. Create a php file:
<?php
$address = '127.0.0.1';
$port = 9000;
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, $address, $port) or die('Unable to bind');
socket_listen($sock);
$client = socket_accept($sock);
echo "connection established: $client";
socket_close($client);
socket_close($sock);
?>
Run it from the command line and load any page in your browser with the following at the end of the url:
?XDEBUG_SESSION_START=nb
If it outputs something like "connection established: Resource id #5", xdebug is working correctly. With that, I reinstalled Java and NetBeans. I told NetBeans NOT to import my existing preferences... Still no connection.
Update2
I installed the phpStorm IDE for Mac. I learned enough about it to get the debugger running with my existing MAMP and xdebug setup. I think this confirms the problem is with NetBeans.
At this point, getting this working seems impossible. :(

I asked the same thing and got this quite good answer: How to track execution time of each line / block of lines / methods in PHP?, beside that i have this answer also on a currently running other question with the same content.
Some additional notes on that (stuff i've collected in other SO posts in my own research with this problem):
The port might be also 9001 (seems to work for some people while 9000 don't).
Switching to PHPStorm IDE is a real alternative that solves this problem (as PHPStorm has included perfectly running xdebug already).
Download a new version of xdebug via the wizard (http://xdebug.org/wizard.php) and if you follow the instructions maybe you will be lucky.
Switching off the firewall might help.
Add to php.ini: xdebug.idekey=netbeans-xdebug.
Find out if you have a xdebug.ini file and add the xdebug related php.ini lines to that file.
you have to un-comment the zend_extension line (i.e. remove the ; at its begninning), so Xdebug is actually loaded.
make sure Xdebug is loaded, calling phpinfo() from a PHP file (just to be sure).

Xdebug will only connect if there is an index.php file in your project folder, so check to make sure you have one.

it works for me now. I have LAMP installed. I modified according to all answers from above, started apache2 and now it flies... i am happy... for some time i thought to switch to phpstorm, but I reconsidered... tweak a little more... et voila. it's working.
Here what I have in php.ini
zend_extension = /usr/lib/php5/20121212/xdebug.so
xdebug.max_nesting_level = 250
xdebug.auto_trace=On
xdebug.remote_enable=On
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_log="/var/log/xdebug.log"
xdebug.trace_output_dir=/var/www/AMRO
xdebug.idekey="netbeans-xdebug"

On clean download and install of netbeans working on xampp, xdebug worked except would not stop at breakpoints. Changed php.ini to: xdebug.remote_enable = 1 (from 0) and xdebug worked as expected!

Related

NetBeans Xdebug Remote Host waiting for connection for infinite time

I am trying to configure Xdebug to my NetBeans IDE which is showing as "Waiting for Connection". I have already spent two days but I didn't find a clue on it.
I am connecting to the code which is in the remote server from my NetBeans IDE using SFTP Connection which is successful.
My Remote Server is a VM with the Cent OS 7.
My Application is configured with nginx, PHP-FPM, PHP 5.6.
I have installed xdebug-2.5.5 in the server and added the following in the php.ini:
zend_extension=/apps/php-fpm/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_autostart=0
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"
;xdebug.remote_connect_back=1
xdebug.profiler_enable_trigger=0
xdebug.remote_log="/mypath/xdebug.log"
I have cross checked that xdebug.so is located in the correct path which I mentioned above.
In my NetBeans, Tools >> Options >> PHP >> Debugging:
Debugging port: 9000
Session ID: netbeans-xdebug
When I start the Debugging in NetBeans IDE, I am seeing the below logs:
Log opened at 2021-11-24 07:11:45
I: Connecting to configured address/port: localhost:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///myserver/location/path/index.php" language="PHP" xdebug:language_version="5.6.14" protocol_version="1.0" appid="4643" idekey="netbeans-xdebug"><engine version="2.5.5"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2017 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="break" reason="ok"><xdebug:message filename="file:///myserver/location/path/index.php" lineno="13"></xdebug:message></response>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2021-11-24 07:11:45
and in NetBeans IDE, "Waiting for Connection" is keep on loading for infinite time.
I am looking for some help to understand what is the problem on this. I am not using any Docker and PhpStorm. Looking forward for some help.
You say "My Remote Server is a VM with the Cent OS 7" but then you have xdebug.remote_host=localhost
Xdebug is the one that connects to the IDE and NOT other way around. If your code is run on another server (another physical machine or inside the VM or some container) then xdebug.remote_host should point to the machine where your IDE is running (an IP address or domain name that can be resolved to that IP; as seen from that server). Unless, of course, you are using reverse SSH tunnel for Xdebug connections.
Right now you are connecting to some service on your server on TCP 9000 port. Extremely likely that it will be php-fpm (that also uses that port: that's one of the reasons why Xdebug v3 have changed the default port to be 9003 BTW). Your Xdebug log is a very short one: a typical response of a service that knows how Xdebug works that just closes the session. php-fpm can do just that.
So a few suggestions:
To ensure that only Xdebug is using this port: change Xdebug port to another number (e.g. 9001 or maybe better 9003 so it will be compatible with Xdebug v3) in both php.ini as well as NetBeans. Do not forget to restart your web server/php-fpm after that (check live settings using phpinfo();).
If no reverse SSH tunnel is used then set xdebug.remote_host to have an IP of the machine with your NetBeans. Quite often that would be the same IP as seen in $_SERVER['REMOTE_HOST'].
NOTE: Since this will be an incoming connection the firewall on your local OS, on your server and your router (if it's outside of your LAN) can prevent such connection. So you would need to ensure that you can receive incoming connections on Xdebug port on your local machine.

Netbeans + xdebug with CLI PHP

I was hoping someone could help with this:
I want to use xdebug to debug CLI PHP on a remote server. I'm not interested in debugging over the web.
I've set xdebug on the remote server, and port 9000 is open on my local machine. I know it connects since when I start debugging I can see it on the remote server's xdebug.log file:
I: Connecting to configured address/port: 192.168.123.195:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1"xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///path/scriptname.php" language="PHP" protocol_version="1.0" appid="15612" idekey="netbeans-xdebug"><engine version="2.3.1"><![CDATA[Xdebug]]></engine>
<author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>
I've two problems:
1) the scriptname.php file above isn't what I'm trying to debug. It's just one of many PHP scripts my remote server's cron runs periodically. I just want to debug what I'm working on at the time.
2) I can't actually debug the file which I do run. When I hit php myfile.php from the command line nothing happens, but on Netbeans I can't actually step into functions, see variable values or anything like that.
Am I missing something here? My php.ini values are as follows:
xdebug.remote_handler=dbgp
xdebug.remote_host=192.168.123.195
xdebug.remote_port=9000
xdebug.remote_mode=req
;xdebug.idekey="netbeans-xdebug"
(when the last line is commented out I do export XDEBUG_CONFIG="idekey=netbeans-xdebug" instead).
I don't even mind moving to a different IDE (I'm running Linux) as long as it works. But it has to be CLI execution on a remote server.
Any ideas? Thanks in advance.

Netbeans waiting for connection to XDEBUG

Netbeans won't connect to xdebug. I've tried suggestions from the following posts:
Debugging IDE's port connection to XDebug: "Waiting to Connect"
netbeans shows "Waiting For Connection (netbeans-xdebug)"
but it doesn't fix my issue.
It seems Netbeans connects to xdebug because while it waits for the connection all request made to the webserver [Apache2] are blocked. Also the port [9001] appears to be in use:
roxy#Pixy011 ~ $ sudo nmap -sS -O 127.0.0.1
Starting Nmap 6.00 ( http://nmap.org ) at 2013-11-28 20:48 EST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000029s latency).
Not shown: 990 closed ports
PORT STATE SERVICE
22/tcp open ssh
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
631/tcp open ipp
902/tcp open iss-realsecure
3306/tcp open mysql
8080/tcp open http-proxy
8081/tcp open blackice-icecap
9001/tcp open tor-orport <---- Opened by java
xdebug.ini: [I have confirmed it is loaded in phpinfo()]
zend_extension=/usr/lib/php5/20100525/xdebug.so
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_host="127.0.0.1"
xdebug.remote_port=9001
xdebug.idekey="netbeans-xdebug"
Netbeans configuration:
Debugger port: 9001
Session ID: netbeans-xdebug
Stop at first line: Checked
All other options are unchecked
Project properties:
Host: 127.0.0.1
Port: 9001
Edit:
I've noticed Netbeans doesn't append the XDEBUG_SESSION_STOP to the URL. I don't think this is related to the issue because Netbeans only opens the page after I close the debugging session.
I've also disabled SELinux
On Ubuntu 13.04 64bit php 5.4.9-4 Xdebug v2.2.3 netbeans 7.4
I have same problem and have solve it by:
1. go on http://xdebug.org/wizard.php follow the instructions to compile your own xdebug.so
2. in netbean 7.4 general options (sorry I haven't reputation 10 to post image)
test connection. be sure correct settings on Proxy:
to me "No Proxy" is working.
3. in php options debugging tab change xdebug setting port to other than 9001 or 9000.
I choose 9002 but you can try until you find a free port (if port is not free nb tell you)
4. in php.ini OR for ubuntu users in /etc/php5/conf.d/20-xdebug.ini
zend_extension=/usr/lib/php5/20100525/xdebug.so #where you ave put your reconpiled xdebug.so
[xdebug]
xdebug.remote_autostart=0
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_port=9002 # the port you have found free and set in netbeans above
xdebug.remote_host=127.0.0.1
xdebug.profiler_enable=0
xdebug.profiler_output_dir="/tmp/"
xdebug.idekey="netbeans-xdebug"
xdebug.remote_log="/home/#user_name#/xdebug.log" #your user name
5. sudo service apache2 restart
after do this I can debug php again.
I had the same issue and I have tried many solution i had found out there but the issue still occured. I have tried to follow the step discribe in enter link description here
and
enter link description here
And that , whttp://localhost/abc/trunk/abc/backend/web/?XDEBUG_SESSION_START=netbeans-xdebughen i debug my project, my netbeats still waiting connection till i have to had the following "?XDEBUG_SESSION_START=netbeans-xdebug" in my url as http://localhost/abc/trunk/abc/backend/web/?XDEBUG_SESSION_START=netbeans-xdebug
so netbeans was able to connect with xdebug
**On Windows 10 with Netbeans 8.0 running Netbeans built in webserver **
The following options in the php.ini file resolved the issue for me:
zend_extension ='C:\path to php installation\ext\php_xdebug-2.5.0-5.6-vc11.dll'
xdebug.remote_enable=on
This issue for me seemed to be resolved by using the full path to the .dll file. Also, because I had spaces in the path name I had to enclose the path in quotes (double vs single did not seem to matter). Also, I had to set the xdebug.remote_enable option. Once I set both options, I was able to select the Debug Application option within Netbeans and the debugger started.
i was facing a similar problem, in my case i had recently update my php version and the xdebug configuration were in the only php5 folder. had simply had to copy the old xdebug configuration to the new php.ini file of the new version and it worked like before.
some of the tips to debug this are:
first check if xdebug is install, run (php -v) if xdebug details aren't there then install and add the configuration.
open phpinfo() under xdebug category check if xdebug configuration is loaded.Check for the following settings.
remote_enable = on,remote_handler=dbgp
I faced the same issue to get xdebug worked in virtualbox ubuntu machine with Netbeans.
PHP version 7.4
Changed following file
"/etc/php/7.4/apache2/conf.d/20-xdebug.ini"
and added following lines
zend_extension="/usr/lib/php/20190902/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_log = "/var/log/xdebug.log"
Plese note that the line below consists double quotes for defining the path.
zend_extension="/usr/lib/php/20190902/xdebug.so"
Had same issue:
$ netstat | grep 9000
...
tcp6 1 0 localhost:9000 localhost:37486 CLOSE_WAIT
Solution: Restart NetBeans.
There was running a dead Process waiting for connections.
Here Netbeans with a running debug session. Note the CLOSE_WAIT and TIME_WAIT.
tcp6 0 0 localhost:9000 localhost:38166 TIME_WAIT
For Xdebug v>=3
If you are still facing issues after trying all above answers. And you have Xdebug version >=3 then only try my steps.
Some settings have been changed in v3.
Xdebug's default debugging port has changed from 9000 to 9003. So change it in php.ini and netbeans IDE.
In php.ini
add xdebug.start_with_request="yes"
add xdebug.client_host = localhost . (The old xdebug.remote_host=localhost is no longer useful in v3)
add xdebug.mode=debug

netbeans shows "Waiting For Connection (netbeans-xdebug)"

I need help to configure xdebug, for debugging projects from IDE netbeans.
These are the features of my components:
XAMPP 1.8.2
PHP: 5.4.16
netbeans: 7.3.1
Apache: 2.4.4 (Win32)
this is the final part of my php.ini file:
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.3-5.4-vc9-nts.dll"
;xdebug.profiler_append = 0
;xdebug.profiler_enable = 1
;xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
;xdebug.trace_output_dir = "C:\xampp\tmp"
when I run phpinfo(), there is no xdebug installed, and when I debug a project from netbeans, it says "Waiting For Connection (netbeans-xdebug)".
can someone help me to configure it?
Have you rectified the issue ? If not then please try this.
1.) php.ini file content
[xDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug-2.2.3-5.4-vc9.dll"
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
;xdebug.remote_host="localhost:81"
xdebug.remote_host=192.168.1.5
;xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.idekey="netbeans-xdebug"
xdebug.remote_host=192.168.1.5 - This is the IPv4 address of my system, I changed to this because I couldn't debug with localhost and 127.0.0.1.
in NetBeans IDE, open Tools-> Options -> PHP -> Debugging. The values of debugger port and Session Id should match with the port and idekey specified in php.ini.
Now save php.ini, restart Apache and try to debug.
Thanks Johnson
When Netbeans starts a Debugging session, it starts two Listeners, one on 0.0.0.0:9000 (all IPv4 IPs the system has), and the other on the IPv6 interface.
If Netbeans and the Web Server are on the same system, ideally XDebug would be configured to send the data back to 127.0.0.1:9000, on which NetBeans would be listening on (and only per session)...
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_autostart=0
xdebug.remote_connect_back=0
If for whatever reason XDebug is not able to report back to 127.0.0.1, or Netbeans is not listening on 127.0.0.1, you can configure XDebug to send the data back to the $_SERVER['REMOTE_ADDR'] of the original request...
xdebug.remote_connect_back=1
This way you don't have to specify the exact IP (i.e., as in the above answer the LAN IP: 192.168.1.5). The downside here is that any source can connect.
If you have further trouble, this...
xdebug.remote_autostart=1
... will also start the debugging process for all requests, and not just for the ones with the proper session start query or cookie. The downside here is that all requests will initiate debug data collection and reporting back (making everything slower, and generating more data).
Though from what I've gathered, the majority of these "Waiting For Connection (netbeans-xdebug)" issues on Windows (with XAMPP, Wamp-Server, etc) are usually a result of Windows Firewall and McAfee (or other firewall and anti-virus software) blocking the connection...
Source: Netbeans "Waiting For Connection (netbeans-xdebug)" Issue
I am a .Net programmer and very new to PHP.
Recently I was trying to host an open source PHP application on my machine(Windows). After the Struggle for 5-6 days I will list the steps which worked for me.
I uninstalled every previous installations of XAMPP and NetBeans and proceeded with fresh installations.
This might not be the solution for everyone but it worked for me and I hope it helps someone.
install XAMPP
install netbeans for PHP.
Open IIS and stop it. It is running on port 80 by default.(I am running XAMPP on port 80 i.e. default, Running on other port might need additional configuration settings)
Open XAMPP control panel and start Apache. If port 80 is free no problem should arise.
Open localhost in browser in should display XAMPP home page.
open phpinfo() link on the left pane and copy all the contents on page.
Go to: http://xdebug.org/wizard.php and paste all the content in TextBox and click Analyze my phpinfo output. It will diplay you the Xdebug file suitable for your configuration.
Download the given Xdebug dll and copy it in C:\xampp\php\ext (Xampp being the default Xampp installation directory)
Goto XAMPP control panel, click on Config button in front of Apache and select php.in,
Find line similar or exacly like,
;zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
(Semicolon means it is commented)
Remove the semicolon and replace the path with the path of dll you just copied like:
zend_extension = "C:\xampp\php\ext\php_xdebug-2.3.2-5.4-vc9.dll"
Similarly find lines
;xdebug.remote_enable = 0
;xdebug.remote_handler = "dbgp"
remove semicolons in front of both lines and make remote_enable = 1
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
Restart Apache server.
Copy your website code under C:/XAMPP/htdocs/(your_website)/
that means your index.php should be at C:/XAMPP/htdocs/(your_website)/index.php
Open Netbeans select New project -> PHP -> PHP project from existing source and select the folder you just copied in htdocs folder.
Set it to run on Local web server.
Set a breakpoint on first line of index.php and debug.
That's it.
Additional settings were suggested on various different posts but above mentioned steps worked perfectly for me.
I want to mention something here about xdebug.remote_host
xdebug.remote_host="127.0.0.1"
Is Not valid. It may work in some cases, but the quotes can also cause issues. Most people don't have issues when using IP addresses in quotes, but this sets a bad precedent. It makes people think that if you want to use a hostname or URL you need to put it in quotes. This is incorrect, urls in quotes will not work.
If you want to debug using a url, you can do this by just putting the url after the equals like this:
xdebug.remote_host=subdomain.mydomain.com
I also want to mention that if you have a port number, don't add it. This doesn't work:
xdebug.remote_host=subdomain.mydomain.com:9000
This is what you want to do:
xdebug.remote_host=subdomain.mydomain.com
xdebug.remote_port=9000
If you do this, I also caution you make sure remote_connect_back is disabled. Like this:
xdebug.remote_connect_back=0
or you can ommit it entirely, like this:
;xdebug.remote_connect_back=1
If remote_connect_back is enabled, it will try and pull your IP address from the incoming connection and ignore the remote_host and port setting.
Xdebug uses plain old TCP to make connections. This is not HTTP. This means tools like Fiddler will not show any packets or information on debugging. If you need to debug, and see if the server is making a call to your IDE there are a few ways you can go about checking.
Wireshark will allow you to see TCP traffic. Also if you are on Windows, Microsoft Message Analyzer can also monitor TCP.
But, if all you are trying to do is remove your IDE is a possible cause of remote debugging problems, I suggest instead you start a local TCP server.
This is a great free java program to start a TCP server: http://sockettest.sourceforge.net/
In the IP Address section, just list 127.0.0.1 or leave it at 0.0.0.0. Then list the port number, which is usually defaulted to 9000 for xdebug.
Once the TCP server is running, open your remote webpage with an xdebug_break(); function call in it. This will tell xdebug on the remote server to start debugging on whatever server and port you listed in your php.ini.
Watch the socket server and see if you get a connection. The first data sent should look something like this:
<init appid="APPID"
idekey="IDE_KEY"
session="DBGP_COOKIE"
thread="THREAD_ID"
parent="PARENT_APPID"
language="LANGUAGE_NAME"
protocol_version="1.0"
fileuri="file://path/to/file">
If you have made it this far, remote debugging is working! Just stop the server and setup your IDE to listen on that port!
If you are like most of us, your developer machine is behind a router with NAT. This means that everyone in your office has the same public IP address. This is a problem because when xdebug contact that IP address to start debugging, it hits the router, and not your computer. The router can be configured to pass certain port numbers to individual computers, but you may not want to do that as that port will be open until you change your router settings back.
Another option is to use SSH. There is a great example of how to do this here: http://stuporglue.org/setting-up-xdebug-with-netbeans-on-windows-with-a-remote-apache-server/#attachment_1305
My preferred option is to use Ngrok. Ngrok is a great tool for redirecting http, https and TCP traffic. In order to use the TCP redirect function you need to sign up for a free account.
Once you have signed up for an account, and added your API key to your computer run this command on the computer that your IDE is on:
ngrok tcp 9000
This will open a tcp (not http) tunnel from the ngrok server to whatever machine you ran the command on. I am using port 9000, you can change this port if your IDE is configured for a different Xdebug port.
This is what you should see:
You will need to see what the url is for the TCP tunnel that was opened. In this example it is:
0.tcp.ngrok.io:14904
For this session, the Xdebug setting on your server should be this:
xdebug.remote_host=0.tcp.ngrok.io
xdebug.remote_port=14904
The URL and port will change each time ngrok is launched. If you want to have the same url and port, you have to upgrade to a paid account. Make sure to restart apache after you make changes to your php.ini.
I just spent hours reading so many answers on this page and others like it, and nobody mentioned what ended up being the solution for me:
Make Sure Your Chosen Port Settings Match in All 3 Locations
My problem was that there are THREE places that the chosen port needs to match. Two of mine said 9001 and one said 9000. I changed them all to 9000.
That was the problem and why Netbeans would only say “Waiting For Connection (netbeans-xdebug)”.
The 3 port setting locations are:
php.ini (xdebug.remote_port=9000)
project properties > Run Configuration > Advanced
Netbeans > Tools > Options > PHP > Debugging
Check also the "windows" firewall settings.
For me it doesn't worked because my LAN network was declared as "Public network".
After i switched it to "Work network" it worked fine.
Try this setting if you have latest version of Xdebug the old version syntax has been changed
https://xdebug.org/docs/upgrade_guide
xdebug.mode=debug
xdebug.start_with_request = Yes
;xdebug.mode=profile
;xdebug.start_with_request=trigger
xdebug.client_host = "localhost"
xdebug.client_port = 9003
xdebug.remote_handler = "dbgp"
xdebug.log = "C:\xampp\tmp\xdebug\xdebug.log"
xdebug.trace_output_dir = "C:\xampp\tmp"
In my case the Apache log showed a PHP warning about not having set date.timezone. Xdebug/netbeans began working as soon as I set it in php.ini and restarted apache.
date.timezone = America/Los_Angeles
This is PHP 5.5.
I'm on Windows with xampp and changed the [XDebug] section of my php.ini (at the bottom) to the following to get it working:
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
Sourced from the Netbeans wiki here: http://wiki.netbeans.org/HowToConfigureXDebug
If you have Apache running, remember to restart it after configuring XDebug and saving php.ini.
Adding this did work for me:
xdebug.idekey=netbeans-xdebug
I my case if I add following in php ini it did not work
zend_extension_ts="C:\PHP\PHP560\ext\php_xdebug-2.4.0rc4-5.6-vc11.dll"
But If I add
zend_extension="C:\PHP\PHP560\ext\php_xdebug-2.4.0rc4-5.6-vc11.dll"
It is working fine.
Having correctly set up the php.ini file, netbeans, port forwarding on the router, I was still getting the wretched "waiting for connection (netbeans-xdebug). I eventually noticed on the netbeans page "Do not forget to set output_buffering = Off in your php.ini file".
So I checked the /etc/php/7.x/apache2/php.ini file and sure enough it's value was 4096. So I reset output_buffering=Off and lo it worked !!!
Hope this helps someone, as the message implies it is a connection error rather than a configuration error.
check this out: Launch XDebug in Netbeans on an external request
another way is to open a new window:
try to go on Project > run configuration > advance
and switch to default, check if it opens another window in the browser
A try could be to start php -i in command window. When redirecting the output an error was
For me it was the FINAL solution because I had a wrong version of Xdebug downloaded
For me it should have been : php_xdebug-2.1.2-5.3-vc6.dll
But I had: php_xdebug-2.2.4-5.3-vc9.dll. So an error occurred from php -i
E:\Programme\php>php -i > myOutputFromPhp
yields following ERROR
Cannot load Xdebug - it was built with configuration API220090626,TS,VC9, whereas
running engine is API220090626,TS,VC6
I had the same problem.
why?
First I installed WAMP, thank Netbeans and they work together as a charm.
Later I installed XAMPP and Localhost sites were run smoothly but NetBeans could never connect to XAMPP (netbeans-xdebug).
At the same time NetBeans were working good with Wamp.
My solution was to go back to Wamp. It is better than nothing.
My PC:
Win-7-32, NetBeans-8.0.2,
wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b
xampp-win32-5.6.8-0-VC11
For Ubuntu users:
sudo su
apt-get install php5-dev php-pear
pecl install xdebug
find / -name 'xdebug.so' 2> /dev/null
it will return something like: /usr/lib/php5/20121212/xdebug.so
vi /etc/php5/apache2/php.ini
add this line: zend_extension="/usr/lib/php5/20121212/xdebug.so"
service apache2 restart
restart IDE
I spent a lot of time trying to get the optimal set up and thing this deserves its own reply, even though #Johnson T A's one it's almost correct.
He says
xdebug.remote_host=192.168.1.5 - This is the IPv4 address of my system, I changed to this because I couldn't debug with localhost and 127.0.0.1.
Well, not everybody can use a private address, or it may be dynamic, or other things. Also, in my case I was suffering from very long wait times before debugging actually started - 30 s or so every time. That was unpractical.
I'm sure everyone having these problems are at least on Windows 7 or so. The problem is related to a mix between name resolution and xdebug. To overcome them make sure that:
Port 9000 is not in use. If that's the case, change it to a unused one, both in php.ini and in netbeans.
Make sure that xdebug.remote_enableis on.
If you want to be able to debug using both localhost and 127.0.0.1 addresses, open \Windows\System32\drivers\etc and make sure that there you have the following lines:
127.0.0.1 localhost
::1 localhost
Make sure that the first line doesnt have a # before it and the second one does have it.
My working php.ini section (I don't need profiler so I disabled it):
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.remote_enable = on
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_port = 9001
xdebug.trace_output_dir = "C:\xampp\tmp"
xdebug.remote_log = "C:\xampp\tmp\xdebug\xdebug.log"
xdebug.idekey = "netbeans-xdebug"
xdebug.remote_autostart = on
xdebug.remote_connect_back = on
Stop netbeans debugger. Restart Apache.
I bet you won't suffer from long waiting times anymore nor strange behaviour with debugger.
Explanation:
Althought in etc/hosts they say "localhost name resolution is handled within DNS itself", for whatever reason it doesn't work well with xdebug if you don't have it explicitely stated in that file. Explicitly putting it seems to do no harm overall, and solves this problem with xdebug. But also you need to explicitly disable the sIPv6 short notation for localhost (::1) in order for all this to work. Don't know the internal reasons but triead all the combinations and this one works for me like a charm.
I had this issue for one project, but not for others. So xdebug was correctly configured, the project settings were ok, but it still did not work.
So I just deleted the nbproject subdirectory, containing the project settings, and created a new project with the existing source. This solved the issue for me.
Select a specific browser for debugging:
Right Click on project -> select Properties
Select categories: Browser then selected a specific browser for debugging
If your xdebug is not working correctly, check your server log:
$ sudo less /var/log/httpd/error_log
To check connections, use this command:
$ sudo netstat -an
After starting debug on netbeans, if you use the netstat command, you can see the port of xdebug (probably it's 80):
tcp6 0 0 192.168.33.10:80 192.168.33.2:49901 ESTABLISHED
The port of netbeans is 9000:
tcp 0 0 192.168.33.10:52024 192.168.33.2:9000 ESTABLISHED
You can change the xdebug's port from here (From the top menu, Tools -> Options -> PHP):
If the connection is not established, it is highly possible that your connection is blocked by your anti-virus program or firewall. You can check it in your anti-virus program or firewall and remove the block as it is a safe connection.
After you make changes to your php.ini or xdebug.ini files, regardless of how you're running your web server, make sure to restart that web server (for example: service httpd restart on CentOS) or Apache will not pick up the changes you've made to that .ini file.
The xdebug package on CentOS is "phpXXu-pecl-xdebug".
Defaults on most recent Xdebugs are usually fine. It's only strictly necessary to get these two values right, somewhere in an Apache .ini file:
xdebug.remote_enable=on
xdebug.remote_host=[DNS entry that resolves to the IP4 of your debugger]
I had the same problem and tried to solve it for hours. I finally found out that the chrome extension ipflood which changes the headers to make it look like you are using a proxy, was the cause.
It works perfectly fine after I disabled it!
Also, consider whether the NTS or the TS version of xdebug is suitable for your case.
Check the Apache log for hints
For Windows users this is what worked for me:
Obtain your phpinfo() output and copy it here: https://xdebug.org/wizard
It will tell you what is the exact dll you have to download.
Copy that dll into C:\xampp\php\ext, and rename it to php_xdebug.dll
Pay attention at the version of xdebug you have installed. That was the key for me! My version of xdebug was version 3 so I had to...
Update php.ini file to have the following (for xdebug v3):
[XDebug]
zend_extension = xdebug
xdebug.mode=debug
xdebug.client_host=localhost
xdebug.client_port=9000
xdebug.idekey="netbeans-xdebug"
Restart Apache Webserver and Netbeans.

Xdebug stopped working, where do I look for errors?

I installed Xdebug and all was fine, until suddenly it stopped working. phpinfo() gives a nice XDebug output with all variables.
php -m | grep deb
also gives twice XDebug (for Zend and PHP), so again looks just fine. My php.ini has these lines:
zend_extension=/usr/lib/php5/20090626/xdebug.so
;extension=xdebug.so
xdebug.remote_host=localhost
xdebug.remote_enable=on
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.remote_connect_back=1
And yet, when running this code with should check XDebug (from Netbeans docs) it's just stuck. So No IDE is working with XDebug.
<?php
$address = '127.0.0.1';
$port = 9001;
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, $address, $port) or die('Unable to bind');
socket_listen($sock);
$client = socket_accept($sock);
echo "connection established: $client";
socket_close($client);
socket_close($sock);
Also, according to XDebug installation, I went twice throught the steps. What is wrong with my config? Thanks.
At the end, left with only two solutions - to reinstall the Ubuntu OS or to install a new VM especially for xdebug, I'm going for the second one.
Funny thing is, everything was working according to the "RTM" (f=freaking). One thing that I couldn't figure out is how to read the logs for XDebug in order to understand where the real problem is.
UPDATE
After some struggling, I deleted every single line related to xdebug from every php.ini that I had. And moved these lines to /etc/php5/conf.d/xdebug.ini. Restarted Apache, and then PHPStorm, and it works.
P.S. in the middle, I tried to install xdebug with pecl, from github, and the standard Ubuntu version. I think the one that I compiled is currently working. And.. the log gets updated as well.
;xdebug configuration
zend_extension = /usr/lib/php5/20090626/xdebug.so
xdebug.remote_host = 127.0.0.1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.remote_autostart=1
xdebug.idekey=PHPSTORM
xdebug.remote_log="/tmp/xdebug.log"
On your server, try this command:
$ netstat -anp | grep CLOSE_WAIT
Any :9000 entries will give you XDebug troubles; consider kill -9 <pid>.
I had this problem too on Ubuntu after updating php. For me, turning on html errors in php.ini got xdebug with Netbeans to work again ...
sudo vi /etc/php5/apache2/php.ini
display_errors = On
html_errors = On
And restart apache:
sudo /etc/init.d/apache2 restart
http://ubuntuforums.org/showpost.php?p=9592364&postcount=14
I checked my
netstat -anp
output and found out that there were number of open sockets (in XDebug port range) by master process on my remote machine [running xDebug].
Killing the 'master' process solved the problem for me.
Seemed like a port overrun situation for me.
Thought the information might be useful to some.
check port is not occupied, check netbeans is configured to listen to that port(i see you have 9001, 9000 is default usually)also when i debug with eclipse i have to "terminate and relaunch" the debug session every now and then since it stops working, never under stood why, i suspect some sort of expired debug session
Check are you putting breakpoints to the right file. Find first file where script enters (front controller). On symfony there can be more than one for example.
In my case after update xdebug to 3 version I just put/set php.ini config
error_reporting=E_ALL
display_startup_errors=1
display_errors=1
and then command php -v show all warnings and errors.
In my case:
Xdebug: [Config] The setting 'xdebug.remote_enable' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_enable (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)

Categories