2

I got vps with ubuntu 18.04 with ssh access and bitoind set up on it. This is my bitcoin.conf file:

testnet=1
prune=35840
maxconnections=12
muxuploadtarget=20
daemon=1
server=1
rpcclienttimeout=5000
rpcuser=[usr]
rpcpassword=[psw]
rpcallowip=0.0.0.0/0

This is my rpc call:

curl --data '{"jsonrpc":"2.0","method":"getwalletinfo","params":[]}' http://[usr]:[psw]@localhost:18332

When it given in vps terminal, that return json response just like it meant to be, but when i got this request on another machine:

curl --data '{"jsonrpc":"2.0","method":"getwalletinfo","params":[]}' http://[usr]:[psw]@[myvpsip]:18332

terminal returns:

curl: (7) Failed to connect to [myvpsip]: Connection refused

This is my result for "sudo netstat -tuwpln" on vps, pasted results only with bitcoind: :

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:18332         0.0.0.0:*               LISTEN      2027/bitcoind       
tcp        0      0 0.0.0.0:18333           0.0.0.0:*               LISTEN      2027/bitcoind       
tcp6       0      0 ::1:18332               :::*                    LISTEN      2027/bitcoind       
tcp6       0      0 :::18333                :::*                    LISTEN      2027/bitcoind   

Already checked firewall and it has Status: inactive. Iptables also empty. Got connection over ssh, so server is able. Also pinged well. I still think that problem is in bitcoin.conf but don't know exactly where is it. Can anyone help solving this problem? I would be really greatful

P.S. Writing script on python and one part of it is bitcoin payments, so really need solution for this. If there easier way for payments would like to familirize.

2
  • Which VPS provider are you using? Many, such as GCP and AWS, block all ports except SSH, HTTP, and HTTPS by default, you may need to open the port using your provider's control panels Commented Jul 9, 2019 at 15:33
  • Thanks for reply. My provider is Hostwinds, in firewall setiing it says All Traffic allowed by default
    – ruhtren
    Commented Jul 9, 2019 at 15:37

2 Answers 2

5

Please keep in mind that exposing your node's RPC interface to the entire internet is considered to be unsafe. RPCs are not encrypted so anything that you send to your node will be in cleartext for any man in the middle to see. This includes things such as your RPC username, RPC password, and wallet password. If an attacker were to see any of this information, they can execute commands on your node including ones that move any Bitcoin stored in its wallet. Attackers can also do other things like force your node onto an alternative blockchain or force your node to connect only to malicious peers.

Instead of exposing your node's RPC interface publicly, you should instead setup a VPN which has your VPS and other computers that will access your node's RPC interface and have the RPC interface exposed to the VPN. This is far safer as the RPCs will be encrypted and only computers within your VPN will be able to access your node.


The reason that you see that error is that Bitcoin Core no longer binds to 0.0.0.0/0 when -rpcallowip=0.0.0.0/0 is set. You must explicitly tell it to bind to 0.0.0.0 using -rpcbind=0.0.0.0. This functionality was removed for the reasons stated above. I highly recommend that you do not do this and instead setup a VPN and then bind your node to your IP address within that VPN.

1
  • Thanks for detailed response, decided to try similar by ssh tunnel with rsa authefication. Seems to be a good solution
    – ruhtren
    Commented Jul 9, 2019 at 17:47
4

If anyone got problem with reaching bitcoin-rpc server located on vps, the best way in my opinion would be port redirecting over shh. By this command:

ssh [user]@[host] -p [port] -L 18332:127.0.0.1:18332

You will be able to send comands to testnet rpc-server via your computer terminal as localhost.

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.