<p>The problem is I guess, your bitcoin.conf says your are running on mainnet because testnet and regtest option are set to 0, but your bitcoin-cli command specifies regtest.</p>
<p>To activate an option in the bitcoin.conf file set the value to one:</p>
<p>In your case</p>
<p>regtest=1</p>

CC BY-SA 4.0
2021-01-27T00:08:58.397Z
see https://jlopp.github.io/bitcoin-core-config-generator/ to genearte a proper bitcoin.conf file
norisgOG
CC BY-SA 4.0
2021-01-27T22:28:03.510Z
hello @norisOG if you show my bitcoin.conf i have the regtest in number 1 and not 0. in the section [regtest]. but thanks to send me the link to generate my conf, Im improve the app.
Aisakk
CC BY-SA 4.0
2021-01-30T10:02:43.823Z
From the bitcoin-core repo it says: If multiple values for the same option are found with the same precedence, the
first one is generally chosen. Because at the beginning you have the the network option regtest=0
norisgOG
CC BY-SA 4.0
2021-02-02T14:43:25.877Z
thnx @norisgOG today Im going teste, that you say me.
Aisakk
CC BY-SA 4.0
2021-02-05T00:04:07.457Z
Well, I had delete my options and create new options and connect, But, I when use bitcoin-cli -regtest setgenerate true 101 to generate satoshi the console send me method not found i use getinfo with -regtest and say the same text. How i can fix this error?
Aisakk
CC BY-SA 4.0
2021-02-08T17:18:06.447Z
so your daemon is running? which system I you running your software on? Did you build it from source? Can you post your new config file and the start command for botch bitcoind your full bitcoin-cli command.
norisgOG
CC BY-SA 4.0
2021-02-08T18:41:06.323Z
hello @norisgOG, yes mi daemon is running. My software es lubuntu 20.04 and answered your question about if my bitcoin is form source, the answer is no, My config is this.
Aisakk
CC BY-SA 4.0
2021-02-08T18:43:46.237Z
rpcallowip = 127.0.0.1
rpcport = 8332
rpcthreads = 10
servidor = 1
regtest = 1
tesnet = 1
[tesnet]
rpcport = 18333
[regtest]
rpcport = 18443
In my config, I am add the rpcuser y rpcpassword , and to start my bitcoind is the same bitcoind -regtest -daemon, then i use bitcoin-cli -regtest <command> my bitcoin core is the version 20.0 and to generate satoshi is generatetoaddress
Aisakk
CC BY-SA 4.0
2021-02-09T19:47:33.433Z
Just delete the config file, and start your bitcoind with: ` bitcoind -regtest -daemon` then without a config file try the `bitcoin-cli -regtest help` to see all commands then you are savely connected. Then to get a better understanding of the command type bitcoin-cli -regtest help generatetoaddress to see further details
norisgOG
CC BY-SA 4.0
2021-01-27T00:07:30.020Z
2021-01-27T00:07:30.020Z
norisgOG
<p>I need generate satoshi in my bitcoin how test and i need use the -tesnet or -regtest, and when I press the command in my shell:
bitcoind -regtest -daemon
return:</p>
<pre><code>Bitcoin Core starting
</code></pre>
<p>bitcoin-cli -regtest setgenerate true 101
return:</p>
<pre><code>error: Could not connect to the server 127.0.0.1:18444

Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
</code></pre>
<p>the command that i use, is the bitcoin core example testing but i cant connect :/.</p>
<p>this is my file bitcoin.conf</p>
<pre><code>##
## bitcoin.conf configuration file. Lines beginning with # are comments.
##

# Network-related settings:

# Note that if you use testnet or regtest, particularly with the options
# addnode, connect, port, bind, rpcport, rpcbind or wallet, you will also
# want to read &quot;[Sections]&quot; further down.

# Run on the test network instead of the real bitcoin network.
testnet=0

# Run a regression test network
regtest=0

# Connect via a SOCKS5 proxy
#proxy=127.0.0.1:9050

# Bind to given address and always listen on it. Use [host]:port notation for IPv6
#bind=&lt;addr&gt;

# Bind to given address and add permission flags to peers connecting to it. Use [host]:port notation for IPv6
#whitebind=perm@&lt;addr&gt;

##############################################################
##            Quick Primer on addnode vs connect            ##
##  Let's say for instance you use addnode=4.2.2.4          ##
##  addnode will connect you to and tell you about the      ##
##    nodes connected to 4.2.2.4.  In addition it will tell ##
##    the other nodes connected to it that you exist so     ##
##    they can connect to you.                              ##
##  connect will not do the above when you 'connect' to it. ##
##    It will *only* connect you to 4.2.2.4 and no one else.##
##                                                          ##
##  So if you're behind a firewall, or have other problems  ##
##  finding nodes, add some using 'addnode'.                ##
##                                                          ##
##  If you want to stay private, use 'connect' to only      ##
##  connect to &quot;trusted&quot; nodes.                             ##
##                                                          ##
##  If you run multiple nodes on a LAN, there's no need for ##
##  all of them to open lots of connections.  Instead       ##
##  'connect' them all to one node that is port forwarded   ##
##  and has lots of connections.                            ##
##       Thanks goes to [Noodle] on Freenode.               ##
##############################################################

# Use as many addnode= settings as you like to connect to specific peers
#addnode=69.164.218.197
#addnode=10.0.0.2:8333

# Alternatively use as many connect= settings as you like to connect ONLY to specific peers
#connect=69.164.218.197
#connect=10.0.0.1:8333

# Listening mode, enabled by default except when 'connect' is being used
listen=1

# Port on which to listen for connections (default: 8333, testnet: 18333, regtest: 18444)
#port=

# Maximum number of inbound+outbound connections.
#maxconnections=

#
# JSON-RPC options (for controlling a running Bitcoin/bitcoind process)
#

# server=1 tells Bitcoin-Qt and bitcoind to accept JSON-RPC commands
server=1
daemon=1
# Bind to given address to listen for JSON-RPC connections.
# Refer to the manpage or bitcoind -help for further details.
#rpcbind=&lt;addr&gt;

# If no rpcpassword is set, rpc cookie auth is sought. The default `-rpccookiefile` name
# is .cookie and found in the `-datadir` being used for bitcoind. This option is typically used
# when the server and client are run as the same user.
#
# If not, you must set rpcuser and rpcpassword to secure the JSON-RPC API.
#
# The config option `rpcauth` can be added to server startup argument. It is set at initialization time
# using the output from the script in share/rpcauth/rpcauth.py after providing a username:
#
# ./share/rpcauth/rpcauth.py alice
# String to be appended to bitcoin.conf:
# rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc02b724e5d095828e0bc8b2456e9ac8757ae3211a5d9b16a22ae
# Your password:
# DONT_USE_THIS_YOU_WILL_GET_ROBBED_8ak1gI25KFTvjovL3gAM967mies3E=
#
# On client-side, you add the normal user/password pair to send commands:
rpcuser=user
rpcpassword=password
#
# You can even add multiple entries of these to the server conf file, and client can use any of them:
# rpcauth=bob:b2dd077cb54591a2f3139e69a897ac$4e71f08d48b4347cf8eff3815c0e25ae2e9a4340474079f55705f40574f4ec99

# How many seconds bitcoin will wait for a complete RPC HTTP request.
# after the HTTP connection is established.
rpcclienttimeout=900

# By default, only RPC connections from localhost are allowed.
# Specify as many rpcallowip= settings as you like to allow connections from other hosts,
# either as a single IPv4/IPv6 or with a subnet specification.

# NOTE: opening up the RPC port to hosts outside your local trusted network is NOT RECOMMENDED,
# because the rpcpassword is transmitted over the network unencrypted.

# server=1 tells Bitcoin-Qt to accept JSON-RPC commands.
# it is also read by bitcoind to determine if RPC should be enabled
#rpcallowip=10.1.1.34/255.255.255.0
#rpcallowip=1.2.3.4/24
#rpcallowip=2001:db8:85a3:0:0:8a2e:370:7334/96

# Listen for RPC connections on this TCP port:
#rpcport=8332    //18332 // 18444
rpcport=8332
# You can use Bitcoin or bitcoind to send commands to Bitcoin/bitcoind
# running on another host using this option:
rpcconnect=127.0.0.1

# Wallet options

# Specify where to find wallet, lockfile and logs. If not present, those files will be
# created as new.
#wallet=&lt;/path/to/dir&gt;

# Create transactions that have enough fees so they are likely to begin confirmation within n blocks (default: 6).
# This setting is over-ridden by the -paytxfee option.
#txconfirmtarget=n

# Pay a transaction fee every time you send bitcoins.
#paytxfee=0.000x

# Miscellaneous options

# Pre-generate this many public/private key pairs, so wallet backups will be valid for
# both prior transactions and several dozen future transactions.
#keypool=100

# Enable pruning to reduce storage requirements by deleting old blocks.
# This mode is incompatible with -txindex and -rescan.
# 0 = default (no pruning).
# 1 = allows manual pruning via RPC.
# &gt;=550 = target to stay under in MiB.
#prune=550

# User interface options

# Start Bitcoin minimized
#min=1

# Minimize to the system tray
#minimizetotray=1

# [Sections]
# Most options apply to mainnet, testnet and regtest.
# If you want to confine an option to just one network, you should add it in the
# relevant section below.
# EXCEPTIONS: The options addnode, connect, port, bind, rpcport, rpcbind and wallet
# only apply to mainnet unless they appear in the appropriate section below.

# Options only for mainnet
[main]

# Options only for testnet
[test]

# Options only for regtest
[regtest]
port=18444
rpcport=18444
rpcconnect=127.0.0.1:18444
rpcuser=user
rpcpassword=password
server=1
daemon=1
listen=1
regtest=1
</code></pre>

CC BY-SA 4.0
2021-01-23T06:15:14.220Z
Are you sure that bitcoind is running? The starting message does not always mean it is actually running. It may be shutting down soon afterwards. Please check and post the debug.log file. It would also be useful to run without `-daemon`.
Ava Chow
<bitcoin-cli>
Why I cant connect bitcoin-cli -regtest
Aisakk
# Why I cant connect bitcoin-cli -regtest

(Asked by: username_0 on 2021-01-22)

I need generate satoshi in my bitcoin how test and i need use the -tesnet or -regtest, and when I press the command in my shell:
bitcoind -regtest -daemon
return:

```
Bitcoin Core starting

```

bitcoin-cli -regtest setgenerate true 101
return:

```
error: Could not connect to the server 127.0.0.1:18444

Make sure the bitcoind server is running and that you are connecting to the correct RPC port.

```

the command that i use, is the bitcoin core example testing but i cant connect :/.

this is my file bitcoin.conf

```
##
## bitcoin.conf configuration file. Lines beginning with # are comments.
##

# Network-related settings:

# Note that if you use testnet or regtest, particularly with the options
# addnode, connect, port, bind, rpcport, rpcbind or wallet, you will also
# want to read "[Sections]" further down.

# Run on the test network instead of the real bitcoin network.
testnet=0

# Run a regression test network
regtest=0

# Connect via a SOCKS5 proxy
#proxy=127.0.0.1:9050

# Bind to given address and always listen on it. Use [host]:port notation for IPv6
#bind=<addr>

# Bind to given address and add permission flags to peers connecting to it. Use [host]:port notation for IPv6
#whitebind=perm@<addr>

##############################################################
##            Quick Primer on addnode vs connect            ##
##  Let's say for instance you use addnode=4.2.2.4          ##
##  addnode will connect you to and tell you about the      ##
##    nodes connected to 4.2.2.4.  In addition it will tell ##
##    the other nodes connected to it that you exist so     ##
##    they can connect to you.                              ##
##  connect will not do the above when you 'connect' to it. ##
##    It will *only* connect you to 4.2.2.4 and no one else.##
##                                                          ##
##  So if you're behind a firewall, or have other problems  ##
##  finding nodes, add some using 'addnode'.                ##
##                                                          ##
##  If you want to stay private, use 'connect' to only      ##
##  connect to "trusted" nodes.                             ##
##                                                          ##
##  If you run multiple nodes on a LAN, there's no need for ##
##  all of them to open lots of connections.  Instead       ##
##  'connect' them all to one node that is port forwarded   ##
##  and has lots of connections.                            ##
##       Thanks goes to [Noodle] on Freenode.               ##
##############################################################

# Use as many addnode= settings as you like to connect to specific peers
#addnode=69.164.218.197
#addnode=10.0.0.2:8333

# Alternatively use as many connect= settings as you like to connect ONLY to specific peers
#connect=69.164.218.197
#connect=10.0.0.1:8333

# Listening mode, enabled by default except when 'connect' is being used
listen=1

# Port on which to listen for connections (default: 8333, testnet: 18333, regtest: 18444)
#port=

# Maximum number of inbound+outbound connections.
#maxconnections=

#
# JSON-RPC options (for controlling a running Bitcoin/bitcoind process)
#

# server=1 tells Bitcoin-Qt and bitcoind to accept JSON-RPC commands
server=1
daemon=1
# Bind to given address to listen for JSON-RPC connections.
# Refer to the manpage or bitcoind -help for further details.
#rpcbind=<addr>

# If no rpcpassword is set, rpc cookie auth is sought. The default `-rpccookiefile` name
# is .cookie and found in the `-datadir` being used for bitcoind. This option is typically used
# when the server and client are run as the same user.
#
# If not, you must set rpcuser and rpcpassword to secure the JSON-RPC API.
#
# The config option `rpcauth` can be added to server startup argument. It is set at initialization time
# using the output from the script in share/rpcauth/rpcauth.py after providing a username:
#
# ./share/rpcauth/rpcauth.py alice
# String to be appended to bitcoin.conf:
# rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc02b724e5d095828e0bc8b2456e9ac8757ae3211a5d9b16a22ae
# Your password:
# DONT_USE_THIS_YOU_WILL_GET_ROBBED_8ak1gI25KFTvjovL3gAM967mies3E=
#
# On client-side, you add the normal user/password pair to send commands:
rpcuser=user
rpcpassword=password
#
# You can even add multiple entries of these to the server conf file, and client can use any of them:
# rpcauth=bob:b2dd077cb54591a2f3139e69a897ac$4e71f08d48b4347cf8eff3815c0e25ae2e9a4340474079f55705f40574f4ec99

# How many seconds bitcoin will wait for a complete RPC HTTP request.
# after the HTTP connection is established.
rpcclienttimeout=900

# By default, only RPC connections from localhost are allowed.
# Specify as many rpcallowip= settings as you like to allow connections from other hosts,
# either as a single IPv4/IPv6 or with a subnet specification.

# NOTE: opening up the RPC port to hosts outside your local trusted network is NOT RECOMMENDED,
# because the rpcpassword is transmitted over the network unencrypted.

# server=1 tells Bitcoin-Qt to accept JSON-RPC commands.
# it is also read by bitcoind to determine if RPC should be enabled
#rpcallowip=10.1.1.34/255.255.255.0
#rpcallowip=1.2.3.4/24
#rpcallowip=2001:db8:85a3:0:0:8a2e:370:7334/96

# Listen for RPC connections on this TCP port:
#rpcport=8332    //18332 // 18444
rpcport=8332
# You can use Bitcoin or bitcoind to send commands to Bitcoin/bitcoind
# running on another host using this option:
rpcconnect=127.0.0.1

# Wallet options

# Specify where to find wallet, lockfile and logs. If not present, those files will be
# created as new.
#wallet=</path/to/dir>

# Create transactions that have enough fees so they are likely to begin confirmation within n blocks (default: 6).
# This setting is over-ridden by the -paytxfee option.
#txconfirmtarget=n

# Pay a transaction fee every time you send bitcoins.
#paytxfee=0.000x

# Miscellaneous options

# Pre-generate this many public/private key pairs, so wallet backups will be valid for
# both prior transactions and several dozen future transactions.
#keypool=100

# Enable pruning to reduce storage requirements by deleting old blocks.
# This mode is incompatible with -txindex and -rescan.
# 0 = default (no pruning).
# 1 = allows manual pruning via RPC.
# >=550 = target to stay under in MiB.
#prune=550

# User interface options

# Start Bitcoin minimized
#min=1

# Minimize to the system tray
#minimizetotray=1

# [Sections]
# Most options apply to mainnet, testnet and regtest.
# If you want to confine an option to just one network, you should add it in the
# relevant section below.
# EXCEPTIONS: The options addnode, connect, port, bind, rpcport, rpcbind and wallet
# only apply to mainnet unless they appear in the appropriate section below.

# Options only for mainnet
[main]

# Options only for testnet
[test]

# Options only for regtest
[regtest]
port=18444
rpcport=18444
rpcconnect=127.0.0.1:18444
rpcuser=user
rpcpassword=password
server=1
daemon=1
listen=1
regtest=1

```

**Tags:** bitcoin-cli

> **Comments:**
> **username_1**: Are you sure that bitcoind is running? The starting message does not always mean it is actually running. It may be shutting down soon afterwards. Please check and post the debug.log file. It would also be useful to run without `-daemon`.  

---

## 1 answers

### Answer by username_2 on 2021-01-27. Score: 0 | Accepted answer

The problem is I guess, your bitcoin.conf says your are running on mainnet because testnet and regtest option are set to 0, but your bitcoin-cli command specifies regtest.

To activate an option in the bitcoin.conf file set the value to one:

In your case

regtest=1

> **Comments:**
> **username_2**: see https://jlopp.github.io/bitcoin-core-config-generator/ to genearte a proper bitcoin.conf file  
> **username_0**: hello @norisOG if you show my bitcoin.conf i have the regtest in number 1 and not 0. in the section [regtest]. but thanks to send me the link to generate my conf, Im improve the app.  
> **username_2**: From the bitcoin-core repo it says: If multiple values for the same option are found with the same precedence, the first one is generally chosen. Because at the beginning you have the the network option regtest=0  
> **username_0**: thnx @username_2 today Im going teste, that you say me.  
> **username_0**: Well, I had delete my options and create new options and connect, But, I when use bitcoin-cli -regtest setgenerate true 101 to generate satoshi the console send me method not found i use getinfo with -regtest and say the same text. How i can fix this error?  
> **username_2**: so your daemon is running? which system I you running your software on? Did you build it from source? Can you post your new config file and the start command for botch bitcoind your full bitcoin-cli command.  
> **username_0**: hello @username_2, yes mi daemon is running. My software es lubuntu 20.04 and answered your question about if my bitcoin is form source, the answer is no, My config is this.  
> **username_0**: rpcallowip = 127.0.0.1 rpcport = 8332 rpcthreads = 10 servidor = 1 regtest = 1 tesnet = 1 [tesnet] rpcport = 18333 [regtest] rpcport = 18443 In my config, I am add the rpcuser y rpcpassword , and to start my bitcoind is the same bitcoind -regtest -daemon, then i use bitcoin-cli -regtest <command> my bitcoin core is the version 20.0 and to generate satoshi is generatetoaddress  
> **username_2**: Just delete the config file, and start your bitcoind with: ` bitcoind -regtest -daemon` then without a config file try the `bitcoin-cli -regtest help` to see all commands then you are savely connected. Then to get a better understanding of the command type bitcoin-cli -regtest help generatetoaddress to see further details  

---

