<p>It looks like a bug: I've also replicated the same behaviour on my machine using the current version, <code>Bitcoin Core Daemon version v0.17.99.0-g2945492424934fa360f86b116184ee8e34f19d0a</code> 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.</p>

<p>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.</p>

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

CC BY-SA 4.0
2019-02-08T22:27:49.093Z
Thanks! Got it to work with the `-rpcport=19832` on the command line (I added it in `/etc/systemd/system/bitcoind.service`) 
RocketNuts
CC BY-SA 4.0
2019-02-08T21:51:40.880Z
2019-02-08T21:51:40.880Z
Alistair Mann
<p>Found the solution: <a href="https://github.com/bitcoin/bitcoin/pull/11862" rel="noreferrer">rpcport needs to be in the [test] section</a></p>

<p>Please update your original config file to read:</p>

<pre>
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
</pre>

<p>And restart the daemon. Also take a look at <a href="https://bitcoin.stackexchange.com/questions/77607/cant-specify-rpcport-for-testnet">Can&#39;t specify rpcport for testnet</a> for related changes to other options. We were being warned what to do in the log file. <code>~/.bitcoin/testnet3/debug.log</code> includes the line <code>Warning: Config setting for -rpcport only applied on test network when in [test] section.</code></p>

<p>We could have picked this up faster had (we read the log file! And if) the <a href="https://github.com/bitcoin/bitcoin/blob/master/share/examples/bitcoin.conf" rel="noreferrer">example bitcoin.conf</a> made a mention of now requiring sections. </p>

<p>Would be great if you could make this the ticked solution instead!</p>

CC BY-SA 4.0
2019-02-08T23:03:37.743Z
2019-02-08T23:03:37.743Z
Alistair Mann
<p>I'm running a testnet bitcoind node and I have been doing RPC calls on the default port 18332.</p>

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

<p><code>rpcport=19832</code></p>

<p>And restarted the bitcoind service. I even restarted the whole machine.</p>

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

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

<p>But somehow the port does change. </p>

<p>Am I doing something wrong? Is the setting called something else than <code>rpcport=xxx</code> ?</p>

<p>I know I can probably also define the port manually on the cmd line (using <code>bitcoind -rpcport=xxx</code> 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>

<p>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).</p>

<p>(edit) FYI here's the complete bitcoin.conf file:</p>

<pre><code>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
</code></pre>

<p>And here is how I perform RPC commands:</p>

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

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

<p>In case my version is relevant, the result of <code>getwalletinfo</code> contains <code>"walletversion": 169900</code>.</p>

CC BY-SA 4.0
2019-02-08T12:45:17.130Z
How you're running the `bitcoind` itself? Could you also try to run just this conf file ? https://pastebin.com/mKWmKs00, also try with `127.0.0.1` instead of `localhost` in the `curl` command.
Roman Kiselenko
CC BY-SA 4.0
2019-02-08T13:04:16.710Z
@Зелёный I start bitcoind with `sudo systemctl start bitcoind` or `sudo systemctl restart bitcoind`. Tried your bitcoin.conf file (and changed the username and password to something new, so I'm sure this .conf file is used) and restarted the service, but unfortunately same result: it allows connection on 18332 (using new user&pasw) but not on 19832. Also tried `127.0.0.1` instead of `localhost` with `curl` but again no difference. Strange huh?
RocketNuts
CC BY-SA 4.0
2019-02-08T13:08:26.887Z
I cant reproduce your problem, because on the same configuration is working for me. Maybe something wrong with your systemctl service, run command and show the result `systemctl cat bitcoind.service`.
Roman Kiselenko
CC BY-SA 4.0
2019-02-08T13:14:51.460Z
@Зелёный Result of `systemctl cat bitcoind.service`: https://pastebin.com/raw/JQS0yuJH Thanks a lot for your attempts to help. Just to be sure, you are also testing with testnet? (not mainnet?)
RocketNuts
CC BY-SA 4.0
2019-02-08T13:28:59.757Z
Yes, I tested it with testnet and mainnet. To be honest IDK, why it's not working for you. Here is my service https://pastebin.com/raw/r4hrPkvt also my bitcoin config exactly like this https://pastebin.com/raw/mKWmKs00.
Roman Kiselenko
CC BY-SA 4.0
2019-02-08T13:34:38.553Z
@Зелёный Hmm very weird. And your walletversion from `getwalletinfo` is also 169900 ?
RocketNuts
CC BY-SA 4.0
2019-02-08T13:41:20.560Z
Yes, it is. Try my service and bitcoin configuration.
Roman Kiselenko
CC BY-SA 4.0
2019-02-08T13:57:31.747Z
@Зелёный Have done that, but unfortunately no difference. Very weird :( Well, thanks for all the help attempts. Much appreciated. I will just keep using the regular port for now, and maybe reinstall my entire machine at some later time.
RocketNuts
CC BY-SA 4.0
2019-02-08T14:41:31.287Z
Could you:
print the result of running "sudo lsof -i | grep bitcoind | grep LISTEN" (you'll need to be give the root password)
And can you also give us the result of running manually: "sudo systemctl start bitcoind; " 
then "/path/to/bitcoind -conf=/home/[your 
 homedir]/.bitcoin/bitcoin.conf". Does it honour the correct port when run manually?
Alistair Mann
CC BY-SA 4.0
2019-02-08T16:40:59.950Z
Oops - that should be "sudo systemctl stop bitcoind"
Alistair Mann
CC BY-SA 4.0
2019-02-08T20:26:00.183Z
@AlistairMann Here's the result: https://pastebin.com/raw/MVcuVnWd When stopping the service (and checking with `sudo systemctl status bitcoind` to be 100% sure it stopped) and then starting manually, the `lsof` output is the same (well, other processIDs, but the three listen ports are the same.
RocketNuts
CC BY-SA 4.0
2019-02-08T20:41:42.850Z
I've deleted my last request because I've managed to replicate your problem on my own machine. Will report back shortly.
Alistair Mann
<bitcoin-core><bitcoind><json-rpc><bitcoin.conf><port>
How to change RPC port for bitcoind? (rpcport=xxx in bitcoin.conf doesn't work)
RocketNuts
# How to change RPC port for bitcoind? (rpcport=xxx in bitcoin.conf doesn't work)

(Asked by: username_0 on 2019-02-08)

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`.

**Tags:** bitcoin-core, bitcoind, json-rpc, bitcoin.conf, port

> **Comments:**
> **username_1**: How you're running the `bitcoind` itself? Could you also try to run just this conf file ? https://pastebin.com/mKWmKs00, also try with `127.0.0.1` instead of `localhost` in the `curl` command.  
> **username_0**: @Зелёный I start bitcoind with `sudo systemctl start bitcoind` or `sudo systemctl restart bitcoind`. Tried your bitcoin.conf file (and changed the username and password to something new, so I'm sure this .conf file is used) and restarted the service, but unfortunately same result: it allows connection on 18332 (using new user&pasw) but not on 19832. Also tried `127.0.0.1` instead of `localhost` with `curl` but again no difference. Strange huh?  
> **username_1**: I cant reproduce your problem, because on the same configuration is working for me. Maybe something wrong with your systemctl service, run command and show the result `systemctl cat bitcoind.service`.  
> **username_0**: @Зелёный Result of `systemctl cat bitcoind.service`: https://pastebin.com/raw/JQS0yuJH Thanks a lot for your attempts to help. Just to be sure, you are also testing with testnet? (not mainnet?)  
> **username_1**: Yes, I tested it with testnet and mainnet. To be honest IDK, why it's not working for you. Here is my service https://pastebin.com/raw/r4hrPkvt also my bitcoin config exactly like this https://pastebin.com/raw/mKWmKs00.  
> **username_0**: @Зелёный Hmm very weird. And your walletversion from `getwalletinfo` is also 169900 ?  
> **username_1**: Yes, it is. Try my service and bitcoin configuration.  
> **username_0**: @Зелёный Have done that, but unfortunately no difference. Very weird :( Well, thanks for all the help attempts. Much appreciated. I will just keep using the regular port for now, and maybe reinstall my entire machine at some later time.  
> **username_2**: Could you: print the result of running "sudo lsof -i | grep bitcoind | grep LISTEN" (you'll need to be give the root password) And can you also give us the result of running manually: "sudo systemctl start bitcoind; "  then "/path/to/bitcoind -conf=/home/[your   homedir]/.bitcoin/bitcoin.conf". Does it honour the correct port when run manually?  
> **username_2**: Oops - that should be "sudo systemctl stop bitcoind"  
> **username_0**: @username_2 Here's the result: https://pastebin.com/raw/MVcuVnWd When stopping the service (and checking with `sudo systemctl status bitcoind` to be 100% sure it stopped) and then starting manually, the `lsof` output is the same (well, other processIDs, but the three listen ports are the same.  
> **username_2**: I've deleted my last request because I've managed to replicate your problem on my own machine. Will report back shortly.  

---

## 2 answers

### Answer by username_2 on 2019-02-08. Score: 5 | Accepted answer

Found the solution: [rpcport needs to be in the [test] section](https://github.com/bitcoin/bitcoin/pull/11862)

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](https://bitcoin.stackexchange.com/questions/77607/cant-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](https://github.com/bitcoin/bitcoin/blob/master/share/examples/bitcoin.conf) made a mention of now requiring sections.

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


---

### Answer by username_2 on 2019-02-08. Score: 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!

> **Comments:**
> **username_0**: Thanks! Got it to work with the `-rpcport=19832` on the command line (I added it in `/etc/systemd/system/bitcoind.service`)   

---

