Recently I was helping someone troubleshoot an issue using PhpStorm and Zend Debugger. In this caseÂ Zend Studio was able to debug an application using Zend DebuggerÂ whileÂ PhpStorm was failing unless an SSH tunnel was used. The error received was:
Host ‘127.0.1.1’ is not allowed to open debug sessions – please configure zend_debugger.allow_hosts in the ini file.Failed to connect to host ‘127.0.0.1’, reason: ‘Connection refused’.
The person experiencing this issue was attempting to debugÂ a site in a VirtualBox virtual machine from the host machine. Both the host machine and the virtual machine were running Ubuntu 14.04. At first glance I thoughtÂ adding 127.0.1.1 to the allowed hosts would do it. But turns out it was more than that.
In this case we knew there was not a firewall blocking access, so it had to be networking.
To start things off I wanted to take a look at what PhpStorm was listening to, so I used the broadcast port 20080 to see this in a browser:
So it appears PhpStorm was attempting to useÂ the IP addresses linked to the host systems ‘localhost’ and ‘hostname’, but not an IP address accessible via the network. This meantÂ the server wouldÂ never be able to send information back to the IDE without the use of an SSH tunnel, because it could not reach 127.0.1.1 or 127.0.0.1 of the host.
Unfortunately PhpStorm doesn’t provide a way to alter the listening IP addresses in the preferences, so we were left with either using an SSH tunnel to allow port forwarding of the listening port (10137) back to the host, or manually informing Zend Debugger where the IDE would beÂ located.
Zend DebuggerÂ Tweak
By default Zend Debugger willÂ automatically attempt to detect the IDE settings, as shown below:
However, this wasn’t working because PhpStorm was not reporting a usable IP address, so we needed to update the settings manually:
NOTE: Checking the box “Use browser’s IP Address” did not fix the issue. The IP address needed to be entered.
With this done, the server now knew where to reach the IDE for debugging sessions. One downside to this is if the host machines IP address changes, this setting will need to be updated.
This post is one in a series on debugging. For others click below:
Edit: Please head out to the PhpStorm ticket system and +1 this fix to make this a thing of the past.Â https://youtrack.jetbrains.com/issue/WI-7465