<p>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. </p>

<p><strong>My Conf:</strong></p>

<pre><code> server=1
 rpcuser=userRPC
 rpcpassword=passRPC
 rpctimeout=30
 rpcallowip=68.65.122.148
 rpcallowip=68.65.122.0/24
 rpcport=8332
</code></pre>

<p><strong>phpfile.php</strong></p>

<pre><code>require_once 'jsonRPCClient.php';

$btc= new jsonRPCClient('http://userRPC:passRPC@127.0.0.1:8332/');

echo "&lt;pre&gt;\n";
print_r($btc-&gt;getinfo());
echo "&lt;/pre&gt;";
</code></pre>

<p>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. </p>

<p><strong>Error response received when running from external server:</strong></p>

<pre><code>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-&gt;__call('getinfo', Array)
#1 /home/coincxby/public_html/node.php(8): jsonRPCClient-&gt;getinfo()
#2 {main}
  thrown in /home/coincxby/public_html/jsonRPCClient.php on line 152
</code></pre>

<p><strong>Successful response when I run locally:</strong></p>

<pre><code>Array
(
    [version] =&gt; 110100
    [protocolversion] =&gt; 70002
    [walletversion] =&gt; 60000
    [balance] =&gt; 0
    [blocks] =&gt; 390322
    [timeoffset] =&gt; 3
    [connections] =&gt; 11
    [proxy] =&gt; 
    [difficulty] =&gt; 93448670796.324
    [testnet] =&gt; 
    [keypoololdest] =&gt; 1419183361
    [keypoolsize] =&gt; 104
    [paytxfee] =&gt; 1.0E-5
    [relayfee] =&gt; 5.0E-5
    [errors] =&gt; Warning: This version is obsolete; upgrade required!
)
</code></pre>

<p>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?</p>

CC BY-SA 3.0
2015-12-26T21:10:41.627Z
Is your external server have curl available?  May be able to get more information on the error.  Error seems odd, like it's connecting but response is invalid.

    curl --user userRPC --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' -H 'content-type: text/plain;' http://68.65.122.148:8332/
Dustin Butler
CC BY-SA 3.0
2015-12-26T21:18:58.270Z
Yea my external server has curl, but I'm confused. I'm using PHP so I'm used to initiating curl, setting the headers and curlopts then executing the curl request... not sure how I would execute the above request you suggested?@DustinButler
m1xolyd1an
CC BY-SA 3.0
2015-12-26T21:35:16.667Z
That is curl command line. Would need to have console access (ssh or remote console) to run it.  I think you want to see what the actual response is from your node.  Maybe look at jsonRPCClient.php on line 152 where it's throwing the exception, and see if you can output the real response. May have a clue in it
Dustin Butler
CC BY-SA 3.0
2015-12-26T21:41:20.450Z
Looking at the code for rcpclient try turning debug on 
$btc= new jsonRPCClient('http://userRPC:passRPC@127.0.0.1:8332/', $debug=true);
Dustin Butler
CC BY-SA 3.0
2015-12-26T21:52:09.240Z
Ok, tried the above, same exact error as in the original post. @DustinButler
m1xolyd1an
<json-rpc><nodes><php>
JSON RPC from external server
m1xolyd1an
# JSON RPC from external server

(Asked by: username_0 on 2015-12-26)

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:passRPC@127.0.0.1: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?

**Tags:** json-rpc, nodes, php

> **Comments:**
> **username_1**: Is your external server have curl available?  May be able to get more information on the error.  Error seems odd, like it's connecting but response is invalid.      curl --user userRPC --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' -H 'content-type: text/plain;' http://68.65.122.148:8332/  
> **username_0**: Yea my external server has curl, but I'm confused. I'm using PHP so I'm used to initiating curl, setting the headers and curlopts then executing the curl request... not sure how I would execute the above request you suggested?@username_1  
> **username_1**: That is curl command line. Would need to have console access (ssh or remote console) to run it.  I think you want to see what the actual response is from your node.  Maybe look at jsonRPCClient.php on line 152 where it's throwing the exception, and see if you can output the real response. May have a clue in it  
> **username_1**: Looking at the code for rcpclient try turning debug on  $btc= new jsonRPCClient('http://userRPC:passRPC@127.0.0.1:8332/', $debug=true);  
> **username_0**: Ok, tried the above, same exact error as in the original post. @username_1  

---

## 0 answers

