Author

Topic: [SOLVED] Failed to connect to <IP> port 18332: Connection refused (code: 0) (Read 262 times)

legendary
Activity: 1161
Merit: 1004
I've managed to fix the issue by myself, so here comes the solution:

First of all Windows CURL requires to escape the quotes, from this:

Code:
curl -v --user username123:password456 --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getinfo","params":[]}' -H 'content-type:text/plain;' http://bitcoindServerIP:18332

To this:

Code:
curl -v --user username123:password456 --data "{\"id\":0, \"method\":\"getblockchaininfo\",\"params\":[]}" -H 'content-type:text/plain;' http://bitcoindServerIP:18332/

Also, in order to establish a connection for sending JSON-RPC commands from remote server I have enabled UDP port 18332 on that external server. Let me also remind you that bitcoind server is only listening to TCP port 18332.
legendary
Activity: 1161
Merit: 1004
I'm aware I should not use rpcallowip = 0.0.0.0/0 but it's just for testing purposes.
Also, if I don't bind RPC to 0.0.0.0:18332 I get this in debug.log:

Code:
2019-06-18T09:58:10Z Binding RPC on address 0.0.0.0 port 18332 failed.

Windows CURL returns HTTP error 500 internal server error instead of 0: (I know getinfo was removed but in that case I should get HTTP 404 error not found)

Code:
curl -v --user username123:password456 --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getinfo","params":[]}' -H 'content-type:text/plain;' http://bitcoindServerIP:18332



legendary
Activity: 1161
Merit: 1004
Good morning,
It's been 2 days I'm not able to send JSON-RPC commands from dedicated server #2 to dedicated server #1 (bitcoind host) because I continue to get CURL error: Failed to connect to port 18332: Connection refused (status code: 0)
Running on CentOS/CloudLinux 7, tested CURL (method getinfo and validateaddress) from two different Linux servers, tested on Bitcoin Core v0.17 (currently running) and v0.18.
Only localhost is able to send RPC commands with success status 200.

bitcoin.conf:

Code:
listen = 1
server = 1
daemon = 1
testnet = 1
prune = 5000

[test]
onlynet = ipv4
rpcuser = username123
rpcpassword = password456
rpcbind = 0.0.0.0:18332
rpcallowip = 0.0.0.0/0

Port 18332 is open to IPv4 connections (TCP):



Jump to: