I'm trying to perform a remote JSON RPC. It works fine using localhost but not if I try to do it from another computer.

Here's what I have so far:

            int index = 0;
        HttpWebRequest webRequest = (HttpWebRequest).Create("http://fakeip:8332");

        webRequest.Credentials = new NetworkCredential("fakeuser", "fakepw");
        /// important, otherwise the service can't desirialse your request properly
        webRequest.ContentType = "application/json-rpc";
        webRequest.Method = "POST";

        JObject joe = new JObject();
        joe.Add(new JProperty("jsonrpc", "1.0"));
        joe.Add(new JProperty("id", "1"));
        joe.Add(new JProperty("method", "getinfo"));
        // params is a collection values which the method requires..
        Dictionary<string, string> Params = new Dictionary<string, string>();
        if (Params.Keys.Count == 0) {
            joe.Add(new JProperty("params", new JArray()));
        } else {
            JArray props = new JArray();
            // add the props in the reverse order!
            for (int i = Params.Keys.Count - 1; i >= 0; i--) {
            joe.Add(new JProperty("params", props));

        // serialize json for the request
        string s = JsonConvert.SerializeObject(joe);
        byte[] byteArray = Encoding.UTF8.GetBytes(s);
        webRequest.ContentLength = byteArray.Length;
        Stream dataStream = webRequest.GetRequestStream();
        dataStream.Write(byteArray, 0, byteArray.Length);

        WebResponse webResponse = webRequest.GetResponse();

which gives this exception:

    Unable to connect to the remote server ---> System.Net.Sockets.SocketException: 
A connection attempt failed because the connected party did not properly respond 
after a period of time, or established connection failed because connected host
 has failed to respond fakeip:8332

I've tried using curl too:

   curl --data-binary 
-H 'content-type:text/plain;' http://fakeuser:fakepw@fakeip:8332

curl: (7) Failed to connect to fakeip port 8332: Timed out

My bitcoin.conf:


Anyone have any ideas?

Edit: rpcbind allows me to make the RPC query using C# but the curl method is still not working.

Running the following:

curl --data-binary 
'{"jsonrpc":"1.0","id":"curltext","method":"getnetworkinfo","params":[]}' -H
 'content-type:text/plain;' http://fakeuser:fakepw@fakeip:8332

results in:

{"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null}

I get the same error for any command.

1 Answer 1


You'll need to specify an IP address to bind the RPC interface to. Since Bitcoin Core 0.18, it's not sufficient to have "rpcallowip=*", as it will by still default still only bind to localhost.

So add:

  • Hi Pieter, big fan. The C# code is working now but I'm getting error code -32700 when using curl. Any idea why? If not, using C# should be enough for what I want to do. Thanks a lot.
    – fon
    Commented Jun 26, 2019 at 3:01
  • The getinfo command was deprecated in version 0.16, and subsequently removed. Use the more specific getblockchaininfo, getpeerinfo, getnetworkinfo, getwalletinfo, ... instead. Commented Jun 26, 2019 at 3:09
  • Oh yeah, I figured that out. The error is the same for any command. The error message is "Parse error".
    – fon
    Commented Jun 26, 2019 at 3:14
  • Can you update your question with the exact command and output? Commented Jun 26, 2019 at 3:15
  • I tried your command on my system and it works fine. Commented Jun 26, 2019 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.