<p>You'll need to expose the ports you want to use, Docker doesn't do this automatically. The port depends on which network you want to use. This is documented on the homepage of the Docker image you're using: <a href="https://github.com/ruimarinho/docker-bitcoin-core#exposing-ports" rel="nofollow noreferrer">https://github.com/ruimarinho/docker-bitcoin-core#exposing-ports</a></p>
<p>Furthermore, when running <code>bitcoin-cli</code> you also need to specify which network you're using, e.g. <code>bitcoin-cli -regtest help</code>.</p>

CC BY-SA 4.0
2022-10-04T16:40:53.910Z
2022-10-04T16:40:53.910Z
stickies-v
<p>I am using this <a href="https://github.com/ruimarinho/docker-bitcoin-core" rel="nofollow noreferrer">docker image</a> and trying to use <code>bitcoin-cli</code> commands. When I run `bitcoin-cli help, I get the error:</p>
<pre><code>root@5c7c6e54f180:/# bitcoin-cli help
error: timeout on transient error: Could not connect to the server 127.0.0.1:8332
</code></pre>
<p>I am running the following docker command:</p>
<pre><code>docker run --rm -it ruimarinho/bitcoin-core \
  -printtoconsole \
  -regtest=1 \
  -rpcallowip=172.17.0.0/16 \
  -rpcauth='foo:7d9ba5ae63c3d4dc30583ff4fe65a67e$9e3634e81c11659e3de036d0bf88f89cd169c1039e6e09607562d54765c649cc'
</code></pre>
<p><code>docker ps</code> returns the following:</p>
<pre><code> ~ docker ps
CONTAINER ID   IMAGE                     COMMAND                  CREATED         STATUS         PORTS                                                              NAMES
5c7c6e54f180   ruimarinho/bitcoin-core   &quot;/entrypoint.sh -pri…&quot;   7 minutes ago   Up 7 minutes   8332-8333/tcp, 18332-18333/tcp, 18443-18444/tcp, 38332-38333/tcp   charming_chatterjee
</code></pre>
<p><strong>I want to connect either testnet or regtest</strong></p>

<bitcoin-core><bitcoind><bitcoin-cli>
Unable to connect Docker based Bitcoin Node
Volatil3
# Unable to connect Docker based Bitcoin Node

(Asked by: username_0 on 2022-10-04)

I am using this [docker image](https://github.com/ruimarinho/docker-bitcoin-core) and trying to use `bitcoin-cli` commands. When I run `bitcoin-cli help, I get the error:

```
root@5c7c6e54f180:/# bitcoin-cli help
error: timeout on transient error: Could not connect to the server 127.0.0.1:8332

```

I am running the following docker command:

```
docker run --rm -it ruimarinho/bitcoin-core \
  -printtoconsole \
  -regtest=1 \
  -rpcallowip=172.17.0.0/16 \
  -rpcauth='foo:7d9ba5ae63c3d4dc30583ff4fe65a67e$9e3634e81c11659e3de036d0bf88f89cd169c1039e6e09607562d54765c649cc'

```

`docker ps` returns the following:

```
 ~ docker ps
CONTAINER ID   IMAGE                     COMMAND                  CREATED         STATUS         PORTS                                                              NAMES
5c7c6e54f180   ruimarinho/bitcoin-core   "/entrypoint.sh -pri…"   7 minutes ago   Up 7 minutes   8332-8333/tcp, 18332-18333/tcp, 18443-18444/tcp, 38332-38333/tcp   charming_chatterjee

```

**I want to connect either testnet or regtest**

**Tags:** bitcoin-core, bitcoind, bitcoin-cli


---

## 1 answers

### Answer by username_1 on 2022-10-04. Score: 2 | Accepted answer

You'll need to expose the ports you want to use, Docker doesn't do this automatically. The port depends on which network you want to use. This is documented on the homepage of the Docker image you're using: <https://github.com/ruimarinho/docker-bitcoin-core#exposing-ports>

Furthermore, when running `bitcoin-cli` you also need to specify which network you're using, e.g. `bitcoin-cli -regtest help`.


---

