0

I'm running a testnet bitcoind node and I have been doing RPC calls on the default port 18332.

I have added this line to ~/.bitcoin/bitcoin.conf:

rpcport=19832

And restarted the bitcoind service. I even restarted the whole machine.

But for some reason it is still accepting RPC calls on port 18332, and trying the same on port 19832 gives "connection refused".

It is definitely using the settings in bitcoin.conf, for example if I change rpcuser or rpcpassword (and restart again) I have to use the new user+password in RPC calls, the old ones don't work anymore.

But somehow the port does change.

Am I doing something wrong? Is the setting called something else than rpcport=xxx ?

I know I can probably also define the port manually on the cmd line (using bitcoind -rpcport=xxx or something) when starting bitcoind, but I want to have everything configured in bitcoin.conf (where it belongs) and have it all started automatically.

P.S. I am connecting on localhost, i.e. on the machine itself. I am also running the ufw firewall, and it is configured to accept connections on both 19832 as well as 18832 (so it's definitely not the firewall that's blocking things here).

(edit) FYI here's the complete bitcoin.conf file:

testnet=1
server=1
daemon=1
txindex=1
rpcuser=XXXXXXXXXXXXXXXXXXXXXXX
rpcpassword=XXXXXXXXXXXXXXXXXXX
rpcallowip=127.0.0.1
rpcport=19832
onlynet=ipv4
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333

And here is how I perform RPC commands:

curl http://XXXXXXXXX:XXXXXXXXX@localhost:18332 -H 'content-type:text/plain;' --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getwalletinfo","params":[]}'

This works OK although note it connects to 18332. If I change localhost:18332 into localhost:19832 it doesn't work anymore (Connection refused).

In case my version is relevant, the result of getwalletinfo contains "walletversion": 169900.

  • Could you add the full bitcoin.conf file? – Зелёный Feb 8 at 12:14
  • @Зелёный added 👍 – RocketNuts Feb 8 at 12:17
  • Also add the full command line you're using to start it – Alistair Mann Feb 8 at 12:20
  • @RocketNuts add this command rpcbind=127.0.0.1:19832 – Зелёный Feb 8 at 12:26
  • @Зелёный Thanks but unfortunately it doesn't seem to help. After adding that line and restarting the service, it still accepts RPC commands on 18332 and not on 19832. I also tried removing rpcallowip=127.0.0.1 (so instead of two separate rpcallowip= and rpcport= lines there was now just one rpcbind=127.0.0.1:19832 line) but again, still the same. – RocketNuts Feb 8 at 12:32
2

Found the solution: rpcport needs to be in the [test] section

Please update your original config file to read:

testnet=1
server=1
daemon=1
txindex=1
rpcuser=XXXXXXXXXXXXXXXXXXXXXXX
rpcpassword=XXXXXXXXXXXXXXXXXXX
rpcallowip=127.0.0.1
onlynet=ipv4
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
[test]
rpcport=19832

And restart the daemon. Also take a look at Can't specify rpcport for testnet for related changes to other options. We were being warned what to do in the log file. ~/.bitcoin/testnet3/debug.log includes the line Warning: Config setting for -rpcport only applied on test network when in [test] section.

We could have picked this up faster had (we read the log file! And if) the example bitcoin.conf made a mention of now requiring sections.

Would be great if you could make this the ticked solution instead!

1

It looks like a bug: I've also replicated the same behaviour on my machine using the current version, Bitcoin Core Daemon version v0.17.99.0-g2945492424934fa360f86b116184ee8e34f19d0a freshly downloaded from github. However I notice @Зелёный above was unable to replicate it, so perhaps the bug is in a library you and I share and he doesn't, rather than in bitcoind. Certainly there are no outstanding issues there that seem relevant.

I'm going to pick through the source to see if I can spot what's happening. Depending on what I find I might open an issue with them. Let me know here and I'll update you.

In the meantime I would suggest adding -rpcport=19832 to your command line - it was always honoured here!

  • Thanks! Got it to work with the -rpcport=19832 on the command line (I added it in /etc/systemd/system/bitcoind.service) 👍 – RocketNuts Feb 8 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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