<p>If you're on Amazon AWS try this:</p>

<pre><code>setsebool -P httpd_can_network_connect 1
</code></pre>

<p>I had the same problem and it took me hours to figure out that the server was blocking connections. I thought it wasn't the problem because my AWS security group allowed it. But apparently the server was blocking it directly.</p>

CC BY-SA 3.0
2017-07-14T19:44:30.037Z
2017-07-14T19:44:30.037Z
Marc Alexander
<p>For anyone trying to connect locally to a wallet:</p>

<p>I managed to get mine working locally by changing <code>rpcallowip</code> and <code>rpcconnect</code> from <code>127.0.0.1</code> to my actual local I.P. address (e.g. <code>192.168.0.2</code>), seems that by using default <code>localhost</code> or <code>127.0.0.1</code> does not always work.</p>

CC BY-SA 4.0
2018-09-03T17:07:39.960Z
2018-09-03T17:07:39.960Z
CAJOGOS
<p>add this to bitcoin.conf</p>

<pre><code>rpcallowip=0.0.0.0/0
</code></pre>

<p>allow all ip</p>

CC BY-SA 4.0
2018-05-18T07:35:33.630Z
This is incredibly insecure. You should only allow the IPs you will be connecting from.
Raghav Sood
CC BY-SA 4.0
2023-05-05T13:11:27.350Z
this allowed me to test locally after hours of trying specific ips.  Will not use for production though.
Anekdotin
CC BY-SA 4.0
2018-05-18T07:16:21.533Z
2018-05-18T07:16:21.533Z
ironman
<p>I am not able to get JSON-RPC response via curl. It seems like is not accepting requests.</p>

<p>My bitcoin.conf</p>

<pre><code>rpcuser=USER
rpcpassword=PASS
server=1
rpcport=9332
</code></pre>

<p>Running daemon</p>

<pre><code>$ bitcoind -conf=~/.bitcoin/bitcoin.conf -daemon
Bitcoin server starting
</code></pre>

<p>Checking cli</p>

<pre><code>$ bitcoin-cli -conf=~/.bitcoin/bitcoin.conf getinfo
{
  "version": 140200,
  "protocolversion": 70015,
  "walletversion": 130000,
  "balance": 0.00000000,
  "blocks": 439348,
  "timeoffset": 0,
  "connections": 8,
  "proxy": "",
  "difficulty": 254620187304.0614,
  "testnet": false,
  "keypoololdest": 1500029964,
  "keypoolsize": 100,
  "paytxfee": 0.00000000,
  "relayfee": 0.00001000,
  "errors": ""
}
</code></pre>

<p>Testing curl</p>

<pre><code>$ curl http://localhost:3333
curl: (7) Failed to connect to localhost port 3333: Connection refused
</code></pre>

<p>Of course, the port is wrong:</p>

<pre><code>$ curl http://localhost:9332
JSONRPC server handles only POST requests
</code></pre>

<p>Making a post</p>

<pre><code>$ curl http://localhost:8332 -H 'content-type:text/plain;' --data-binary ''
</code></pre>

<p>The output is always empty, doesn't matter if I add data or user,password. Is always empty:</p>

<pre><code>$ curl http://localhost:9332 -H 'content-type:text/plain;' --data-binary ''
$ curl http://localhost:9332 -H 'content-type:text/plain;' --data-binary ''
$ curl http://USER:PASS@localhost:9332 -H 'content-type:text/plain;' --data-binary ''
$ curl http://USER:PASS@localhost:9332 -H 'content-type:text/plain;' --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getinfo","params":[]}'
$ curl --user USER:PASS http://localhost:9332 -H 'content-type:text/plain;' --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getinfo","params":[]}'
</code></pre>

<p>Any ideas why is this happening? Don't know what else to try.</p>

CC BY-SA 3.0
2017-07-15T04:41:39.030Z
Can you add the verbose option and tell us what is says?  
 `-v / --verbose`
m1xolyd1an
<bitcoind><json-rpc><bitcoin-cli><bitcoin.conf>
curl returns empty output when json-rpc
Enzo
# curl returns empty output when json-rpc

(Asked by: username_0 on 2017-07-14)

I am not able to get JSON-RPC response via curl. It seems like is not accepting requests.
My bitcoin.conf
rpcuser=USER
rpcpassword=PASS
server=1
rpcport=9332

Running daemon
$ bitcoind -conf=~/.bitcoin/bitcoin.conf -daemon
Bitcoin server starting

Checking cli
$ bitcoin-cli -conf=~/.bitcoin/bitcoin.conf getinfo
{
  "version": 140200,
  "protocolversion": 70015,
  "walletversion": 130000,
  "balance": 0.00000000,
  "blocks": 439348,
  "timeoffset": 0,
  "connections": 8,
  "proxy": "",
  "difficulty": 254620187304.0614,
  "testnet": false,
  "keypoololdest": 1500029964,
  "keypoolsize": 100,
  "paytxfee": 0.00000000,
  "relayfee": 0.00001000,
  "errors": ""
}

Testing curl
$ curl http://localhost:3333
curl: (7) Failed to connect to localhost port 3333: Connection refused

Of course, the port is wrong:
$ curl http://localhost:9332
JSONRPC server handles only POST requests

Making a post
$ curl http://localhost:8332 -H 'content-type:text/plain;' --data-binary ''

The output is always empty, doesn't matter if I add data or user,password. Is always empty:
$ curl http://localhost:9332 -H 'content-type:text/plain;' --data-binary ''
$ curl http://localhost:9332 -H 'content-type:text/plain;' --data-binary ''
$ curl http://USER:PASS@localhost:9332 -H 'content-type:text/plain;' --data-binary ''
$ curl http://USER:PASS@localhost:9332 -H 'content-type:text/plain;' --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getinfo","params":[]}'
$ curl --user USER:PASS http://localhost:9332 -H 'content-type:text/plain;' --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getinfo","params":[]}'

Any ideas why is this happening? Don't know what else to try.

**Tags:** bitcoind, json-rpc, bitcoin-cli, bitcoin.conf

> **Comments:**
> **username_1**: Can you add the verbose option and tell us what is says?    `-v / --verbose`  

---

## 3 answers

### Answer by username_2 on 2017-07-14. Score: 1 | Accepted answer

If you're on Amazon AWS try this:
setsebool -P httpd_can_network_connect 1

I had the same problem and it took me hours to figure out that the server was blocking connections. I thought it wasn't the problem because my AWS security group allowed it. But apparently the server was blocking it directly.


---

### Answer by username_3 on 2018-09-03. Score: 1

For anyone trying to connect locally to a wallet:

I managed to get mine working locally by changing `rpcallowip` and `rpcconnect` from `127.0.0.1` to my actual local I.P. address (e.g. `192.168.0.2`), seems that by using default `localhost` or `127.0.0.1` does not always work.


---

### Answer by username_4 on 2018-05-18. Score: -1

add this to bitcoin.conf
rpcallowip=0.0.0.0/0

allow all ip

> **Comments:**
> **username_5**: This is incredibly insecure. You should only allow the IPs you will be connecting from.  
> **username_6**: this allowed me to test locally after hours of trying specific ips.  Will not use for production though.  

---

