How do I debug connection problems while testing Deploy module while using local host? I'm attempting to properly set up between the Deploy Module between these two by follow these instructions. I've used Drush QuickDrupal to set up two new Drupal 7 instances.  

$ drush qd d7-deploy-stage
$ drush qd d7-deploy-live


Initially, I ran them as on the same host machine via PHP's internal development server 

$ php -S localhost:8000 # d7-deploy-stage
$ php -S localhost:9000 # d7-deploy-live


The end point is listed as http://localhost:9000/services/rest and the authentication (and only user) is admin with password of admin. 

However upon a cron run on the d7-deploy-stage instance I 


  DeployAuthenticationException: Authentication error:-111 Connection refused in DeployAuthenticatorSession->deploy()


Question(s): How would I begin to debug this? Since the error reads "connection refused", I'm also curious if I start the servers with a fully qualified domain name (or my machine's IP) or if the port numbers an issue in the addressing

What I've tried so far:

The Patch:
The '#31' has failed with the following output patch -p1 &lt; deploy-404_CSRF_error-2017767-31.patch


  patching file plugins/DeployAuthenticatorSession.inc Hunk #1 FAILED at
  76. 1 out of 1 hunk FAILED -- saving rejects to file plugins/DeployAuthenticatorSession.inc.rej


Update 

On both instances, based this answer below, I downloaded the 'add start up .ht.route' patch, applied and restarted

wget https://www.drupal.org/files/issues/add_a_startup-1543858-58.patch
patch &lt; add_a_startup-1543858-58.patch to each instance.
php -S public-ip-number:8000 .ht.router.php # stage
php -S public-ip-number:9000 .ht.router.php # live 


The error on drush cron has changed 


  WD deploy: DeployAuthenticationException: Authentication error: 404 Not found : Could not find resource user. in DeployAuthenticatorSession deploy() (line 76 modules/deploy/plugins/DeployAuthenticatorSession.inc).
There are few issues with your examples.


You're missing routing-script for the built-in PHP web server. It's recommended to use since you're using PHP built-in web server and by default it may have some problems handling certain clean URLs (for example URI containing dots are treated as direct files). So you should apply this patch from #1543858 and re-run you server as below (same file you can use for both Drupal 7 &amp; 8):

php -S localhost:8000 .ht.router.php

You should use -l in order to specify URI of the Drupal site to use, so your code knows what's your proper hostname (since the fail is related to the connectivity issue).

drush -v -l http://localhost:8000/ cron



If you still have Connection refused, you should check where the code is trying to connect and check the connection (e.g. wrong configuration or firewall in place). To debug the connectivity issue, on OS X you can use dtruss, on Linux this can be debugged by strace, e.g.

strace -e trace=network -fp $(pgrep -fn php)