How to call rpc from outside?

I have a node on the Linux server.
And I can call RPC from the server.
But I can’t call from my computer to the node by IP.
curl --user admin --data-binary ‘{“jsonrpc”: “1.0”, “id”:“curltest”, “method”: “z_listaddresses”, “params”: }’ -H ‘content-type: text/plain;’ http:// 35.21.21.11:18232/
return error message: Failed to connect to 35.21.21.11port 18232: Connection refused

And I checked the port and see:
ubuntu@instance-1-zcash-testnet:~$ netstat -tulpn | grep 18232
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1 :18232 0.0.0.0:* LISTEN 1172/zcashd
tcp6 0 0 ::1:18232 :::* LISTEN 1172/zcashd

this is my config:

rpcuser=admin
rpcpassword=admin
testnet=1
server=1
rpcbind=0.0.0.0
rpcport=18232
experimentalfeatures=1
txindex=1
insightexplorer=1
rpcconnect=0.0.0.0
bind=0.0.0.0

Can you help me to config? thanks!

Does your cloud provider have its own firewall settings that you need to configure to allow incoming data to 18232? On AWS this would look like an issue with the security group

2 Likes

Caveat :

Using the RPC port over a remote interface is not really recommended, because that will cause the rpcpassword to be transmitted over the network unencrypted, allowing any observer to steal your keys + Zcash and take over the OS account running zcashd.

with that said, you can modify your zcash.conf file and add rpcallowip cofig.

rpcallowip=172.17.0.0/16

the IP Address should be added in the CIDR notation.

2 Likes

Thank you for your answer!
if it is not really recommended
So how do I can create new address, check balance, transfer from my server(api)?
the zcash node is a private node of our server.

the caveat is to make sure that you are aware of the security implications of enabling RPC calls from other machines / nodes.

the threat model varies on the use case and the steps you have to make sure your node is Secure will depend on it.

1 Like