<p>Try changing port number in bitcoin.conf.
open file</p>

<pre><code>nano ~/.bitcoin/bitcoin.conf
</code></pre>

<p>add new line</p>

<blockquote>
  <p>rpcport=18332;</p>
</blockquote>

<p>save the file and restart bitcoind</p>

CC BY-SA 3.0
2018-03-21T11:58:23.503Z
This is only the regtest RPC port then?
Willtech
CC BY-SA 3.0
2018-03-21T19:53:51.090Z
This will effect all instances of `bitcoind` that are started, regardless of network.
Ava Chow
CC BY-SA 3.0
2018-03-22T06:45:37.970Z
@Willtech I think it is
Prayag k
CC BY-SA 3.0
2018-03-21T08:44:28.307Z
2018-03-21T08:44:28.307Z
Blockchain geek
<p>Adding <em>rpcport=18332</em> <strong>temporarily</strong> solve your problem. If you want to run <strong>mainnet</strong> or <strong>testnet</strong> at the same time when <strong>regtest</strong> is running, you <em>wont be able to use them</em>, it is because when you assign <code>rpcport=xyz</code> all  bitcoin instances will try to interact through same rpcport when daemon is started but at one time only single daemon can access single port number.But in your case all three daemons tries to take rpcport as 18332.</p>

<p>Infact what you can do is, try to get connected to default rpc port for regtest by typing command:</p>

<blockquote>
  <p>bitcoind -regtest -daemon -rpcport=18443</p>
</blockquote>

<pre><code>Mainnet:8332 
Testnet:18332 
Regtest:18443`
</code></pre>

<p><em>Note:For bitcore v15 rpc port is same for testnet and mainnet where as in v16 rpc port is diffrent for all of them</em></p>

CC BY-SA 3.0
2018-03-23T05:57:45.677Z
From their docs, for testnet&regtest port is same. ie.18832. Is there a different port for regtest?!
Prayag k
CC BY-SA 3.0
2018-03-23T07:51:02.203Z
@Prayagk   For bitcore v15 rpc port is same for testnet and mainnet where as in v16 rpc port is diffrent for all of them
Parishilan Rayamajhi
CC BY-SA 3.0
2018-03-23T08:21:37.683Z
ok..that's new for me
Prayag k
CC BY-SA 3.0
2018-03-23T08:37:09.897Z
you can see which version you using with command getinfo
Parishilan Rayamajhi
CC BY-SA 3.0
2018-03-22T22:06:13.190Z
2018-03-23T07:49:58.647Z
2018-03-23T07:49:58.647Z
Parishilan Rayamajhi
<p>I have started bitcoin daemon with -regtest flag. The output was </p>

<blockquote>
  <p>Bitcoin server starting</p>
</blockquote>

<p>But, when I run</p>

<pre><code>bitcoin-cli -regtest generate 101
</code></pre>

<p>command, it shows </p>

<blockquote>
  <p>error: couldn't connect to server: unknown (code -1) (make sure server
  is running and you are connecting to the correct RPC port)</p>
</blockquote>

<p>How this happens?</p>

<bitcoin-core><bitcoind><rpc-error-25>
Problem with Bitcoin Core’s regression test mode
Prayag k
# Problem with Bitcoin Core’s regression test mode

(Asked by: username_0 on 2018-03-21)

I have started bitcoin daemon with -regtest flag. The output was

> Bitcoin server starting

But, when I run

```
bitcoin-cli -regtest generate 101

```

command, it shows

> error: couldn't connect to server: unknown (code -1) (make sure server
> is running and you are connecting to the correct RPC port)

How this happens?

**Tags:** bitcoin-core, bitcoind, rpc-error-25


---

## 2 answers

### Answer by username_1 on 2018-03-21. Score: 1 | Accepted answer

Try changing port number in bitcoin.conf.
open file

```
nano ~/.bitcoin/bitcoin.conf

```

add new line

> rpcport=18332;

save the file and restart bitcoind

> **Comments:**
> **username_2**: This is only the regtest RPC port then?  
> **username_3**: This will effect all instances of `bitcoind` that are started, regardless of network.  
> **username_0**: @username_2 I think it is  

---

### Answer by username_4 on 2018-03-22. Score: 1

Adding *rpcport=18332* **temporarily** solve your problem. If you want to run **mainnet** or **testnet** at the same time when **regtest** is running, you *wont be able to use them*, it is because when you assign `rpcport=xyz` all bitcoin instances will try to interact through same rpcport when daemon is started but at one time only single daemon can access single port number.But in your case all three daemons tries to take rpcport as 18332.

Infact what you can do is, try to get connected to default rpc port for regtest by typing command:

> bitcoind -regtest -daemon -rpcport=18443

```
Mainnet:8332 
Testnet:18332 
Regtest:18443`

```

*Note:For bitcore v15 rpc port is same for testnet and mainnet where as in v16 rpc port is diffrent for all of them*

> **Comments:**
> **username_0**: From their docs, for testnet&regtest port is same. ie.18832. Is there a different port for regtest?!  
> **username_4**: @username_0   For bitcore v15 rpc port is same for testnet and mainnet where as in v16 rpc port is diffrent for all of them  
> **username_0**: ok..that's new for me  
> **username_4**: you can see which version you using with command getinfo  

---

