I'm having trouble connecting to my node via JSON RPC from an external server. On the same machine, I'm able to pass the commands through bitcoin-cli and also locally I am able to run this PHP file which passes successfully. Once I try to do the same from an external source, I receive an error. I've allowed my webservers IP, under the conf file as rpcallowip. I know it's default it to only accept local requests, but I thought as long as I enter in the rpcallowip then I would be able to do the same from another server. I've even tried to add a range on my IPs allowed, no luck.
My Conf:
server=1
rpcuser=userRPC
rpcpassword=passRPC
rpctimeout=30
rpcallowip=68.65.122.148
rpcallowip=68.65.122.0/24
rpcport=8332
phpfile.php
require_once 'jsonRPCClient.php';
$btc= new jsonRPCClient('http://userRPC:[email protected]:8332/');
echo "<pre>\n";
print_r($btc->getinfo());
echo "</pre>";
The above works perfectly when running locally. I'll change the above IP address to my node and then try to run it on an external server and I get a blank response as if my node isn't even running.
Error response received when running from external server:
Fatal error: Uncaught exception 'Exception' with message 'Incorrect response id (request id: 1, response id: )' in /home/coincxby/public_html/jsonRPCClient.php:152
Stack trace:
#0 /home/coincxby/public_html/node.php(8): jsonRPCClient->__call('getinfo', Array)
#1 /home/coincxby/public_html/node.php(8): jsonRPCClient->getinfo()
#2 {main}
thrown in /home/coincxby/public_html/jsonRPCClient.php on line 152
Successful response when I run locally:
Array
(
[version] => 110100
[protocolversion] => 70002
[walletversion] => 60000
[balance] => 0
[blocks] => 390322
[timeoffset] => 3
[connections] => 11
[proxy] =>
[difficulty] => 93448670796.324
[testnet] =>
[keypoololdest] => 1419183361
[keypoolsize] => 104
[paytxfee] => 1.0E-5
[relayfee] => 5.0E-5
[errors] => Warning: This version is obsolete; upgrade required!
)
The only difference between the two is I change the target IP in the PHP file, and I'm running from an external server. Any ideas why I can't hit my locally running node from an external server?