JSON RPC library unable to connect to bitcoind?
As @Bittylicious mentioned the JSON-RPC is a little bit buggy

https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#PHP

Note: The jsonRPCClient library uses fopen() and will throw an exception saying "Unable to connect" if it receives a 404 or 500 error from bitcoind. This prevents you from being able to see error messages generated by bitcoind (as they are sent with status 404 or 500).

You have an option use EasyBitcoin instead, that will throw more accurate error messages and its pretty much the same than JSON-RPC

&lt;?php
 require_once 'YOUR_FOLDER/easybitcoin.php';
 $rpc_host = 'YOUR_IP';
 $rpc_port = 'YOUR_PORT';
 $rpc_user = 'YOUR_USER';
 $rpc_pass = 'YOUR_KEY';
 $bitcoin = new Bitcoin($rpc_user, $rpc_pass, $rpc_host, $rpc_port);
 print_r($bitcoin-&gt;getinfo());
 print_r($bitcoin-&gt;listaccounts());
 print_r($bitcoin-&gt;listreceivedbyaddress(0, true));
?&gt;


Hope this helps!