Author

Topic: Bitcoin-CLI - Cannot connect to the server (Read 129 times)

newbie
Activity: 13
Merit: 0
December 19, 2022, 01:57:55 PM
#9
It's normal there is no genesis black since I'm trying to locally generate a blockchain based Bitcoin Core. For this purpose, I have changed the port, reproduce a Genesis block hash, etc. and succesfully rebuilt and compile without error.
There is a chance you've screwed it up with reproduction, and have a logical error (which wouldn't appear after compiling). But, I doubt that's the case.

The above error message started after I've created the bitcoin.conf file.
Does it print it if you delete bitcoin.conf?


After I deleted bitcoin.conf then run :
Code:
bitcoind -debug -printtoconsole -regtest


It was then printing in an unlimited loop [in contrary to yesterday when the print was limited (maybe because I restarted my computer today)]  the following (I ended the process using the top command):

Quote
user1@UBUNTU-DESKTOP:~/code/bitcoin$ bitcoind -debug -printtoconsole -regtest
2022-12-19T18:36:05Z Bitcoin Core version v24.99.0-968f03e65c98-dirty (release build)
2022-12-19T18:36:05Z Using the 'sse4(1way),sse41(4way)' SHA256 implementation
2022-12-19T18:36:05Z Default data directory /home/user1/.bitcoin
2022-12-19T18:36:05Z Using data directory /home/user1/.bitcoin/regtest
2022-12-19T18:36:05Z Config file: /home/user1/.bitcoin/bitcoin.conf (not found, skipping)
2022-12-19T18:36:05Z Command-line arg: debug=""
2022-12-19T18:36:05Z Command-line arg: printtoconsole=""
2022-12-19T18:36:05Z Command-line arg: regtest=""
2022-12-19T18:36:05Z Using at most 125 automatic connections (1024 file descriptors available)
2022-12-19T18:36:05Z Using 16 MiB out of 16 MiB requested for signature cache, able to store 524288 elements
2022-12-19T18:36:05Z Using 16 MiB out of 16 MiB requested for script execution cache, able to store 524288 elements
2022-12-19T18:36:05Z Script verification uses 1 additional threads
2022-12-19T18:36:05Z scheduler thread start
2022-12-19T18:36:05Z [http] Allowing HTTP connections from: 127.0.0.0/8 ::1/128
2022-12-19T18:36:05Z [libevent:debug] event_add: event: 0x563eb981fe30 (fd 10), EV_READ    call 0x7ffa0786d1c0
2022-12-19T18:36:05Z [libevent:debug] Epoll ADD(1) on fd 10 okay. Old events were 0; read change was 1 (add); write change was 0 (none); close change was 0 (none)
2022-12-19T18:36:05Z Binding RPC on address ::1 port 19084
2022-12-19T18:36:05Z [libevent:debug] event_add: event: 0x563eb98205d8 (fd 11), EV_READ    call 0x7ffa0787a230
2022-12-19T18:36:05Z [libevent:debug] Epoll ADD(1) on fd 11 okay. Old events were 0; read change was 1 (add); write change was 0 (none); close change was 0 (none)
2022-12-19T18:36:05Z [libevent:debug] Bound to port 19084 - Awaiting connections ...
2022-12-19T18:36:05Z Binding RPC on address 127.0.0.1 port 19084
2022-12-19T18:36:05Z [libevent:debug] event_add: event: 0x563eb980a6b8 (fd 12), EV_READ    call 0x7ffa0787a230
2022-12-19T18:36:05Z [libevent:debug] Epoll ADD(1) on fd 12 okay. Old events were 0; read change was 1 (add); write change was 0 (none); close change was 0 (none)
.
.
.
2022-12-19T18:39:25Z Shutdown: done

As one can see, the process still connecting to port 19084 [despite of bitcoin.conf file being now deleted (with its associated .bitcoin folder)].
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
December 19, 2022, 01:31:51 PM
#8
It's normal there is no genesis black since I'm trying to locally generate a blockchain based Bitcoin Core. For this purpose, I have changed the port, reproduce a Genesis block hash, etc. and succesfully rebuilt and compile without error.
There is a chance you've screwed it up with reproduction, and have a logical error (which wouldn't appear after compiling). But, I doubt that's the case.

The above error message started after I've created the bitcoin.conf file.
Does it print it if you delete bitcoin.conf?

I supposed Bitcoin Core automatically generate a local genesis block if is this last does not exist.
It doesn't make sense. If the genesis block is not found, it's meaningless to create a new one automatically, because it's ensured that the network isn't going to accept you.
newbie
Activity: 13
Merit: 0
December 19, 2022, 01:23:52 PM
#7
Quote
2022-12-19T10:43:04Z Error: Incorrect or no genesis block found. Wrong datadir for network?
There's your problem.

It's normal there is no genesis black since I'm trying to locally generate a blockchain based Bitcoin Core. For this purpose, I have changed the port, reproduce a Genesis block hash, etc. and succesfully rebuilt and compile without error.

The above error message started after I've created the bitcoin.conf file.

I supposed Bitcoin Core automatically generate a local genesis block if is this last does not exist.


 
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
December 19, 2022, 12:58:57 PM
#6
Quote
2022-12-19T10:43:04Z Error: Incorrect or no genesis block found. Wrong datadir for network?
There's your problem.
newbie
Activity: 13
Merit: 0
December 19, 2022, 11:47:35 AM
#5
And what logs says?

Code:
tail -f .bitcoin/debug.log

On the other hand - is .cookie file created? Did you try to connect to server using that file instead of hardcoded password?

It seems no .cookie file has been creates since I receive not output doing a search with the following on /home/user1/:

$ find . -name "*.cookie"
$ find . -name ".cookie"

Yes, I tried to login using the bitcoin.conf file I created in .bitcoin.
newbie
Activity: 13
Merit: 0
December 19, 2022, 11:34:18 AM
#4
but apparently bitcoind stopped running for an unknown reason.
Then this should be solved first before the original question since this must be the vey reason why bitcoin-cli can't query bitcoind.

For that, provide the whole logs as instructed above.

Quote
2022-12-19T10:43:03Z Bitcoin Core version v24.99.0-968f03e65c98-dirty (release build)
2022-12-19T10:43:03Z Using the 'sse4(1way),sse41(4way)' SHA256 implementation
2022-12-19T10:43:03Z Default data directory /home/user1/. bitcoin
2022-12-19T10:43:03Z Using data directory /home/user1/. bitcoin
2022-12-19T10:43:03Z Config file: /home/user1/. bitcoin/ bitcoin.conf
2022-12-19T10:43:03Z Config file arg: rpcallowip="127.0.0.1"
2022-12-19T10:43:03Z Config file arg: rpcbind=****
2022-12-19T10:43:03Z Config file arg: rpcpassword=****
2022-12-19T10:43:03Z Config file arg: rpcport="19084"
2022-12-19T10:43:03Z Config file arg: rpcuser=****
2022-12-19T10:43:03Z Config file arg: server="1"
2022-12-19T10:43:03Z Command-line arg: daemon=""
2022-12-19T10:43:03Z Command-line arg: debug=""
2022-12-19T10:43:03Z Using at most 125 automatic connections (1024 file descriptors available)
2022-12-19T10:43:03Z Using 16 MiB out of 16 MiB requested for signature cache, able to store 524288 elements
2022-12-19T10:43:03Z Using 16 MiB out of 16 MiB requested for script execution cache, able to store 524288 elements
2022-12-19T10:43:03Z Script verification uses 1 additional threads
2022-12-19T10:43:03Z scheduler thread start
2022-12-19T10:43:03Z [http] Allowing HTTP connections from: 127.0.0.0/8 ::1/128 127.0.0.1/32
2022-12-19T10:43:03Z [libevent:debug] event_add: event: 0x55ade8d64610 (fd 10), EV_READ    call 0x7f981e6d81c0
2022-12-19T10:43:03Z [libevent:debug] Epoll ADD(1) on fd 10 okay. Old events were 0; read change was 1 (add); write change was 0 (none); close change was 0 (none)
2022-12-19T10:43:03Z Binding RPC on address 127.0.0.1 port 19084
2022-12-19T10:43:03Z [libevent:debug] event_add: event: 0x55ade8d64708 (fd 11), EV_READ    call 0x7f981e6e5230
2022-12-19T10:43:03Z [libevent:debug] Epoll ADD(1) on fd 11 okay. Old events were 0; read change was 1 (add); write change was 0 (none); close change was 0 (none)
2022-12-19T10:43:03Z [libevent:debug] Bound to port 19084 - Awaiting connections ...
2022-12-19T10:43:03Z [http] Initialized HTTP server
2022-12-19T10:43:03Z [http] creating work queue of depth 16
2022-12-19T10:43:03Z [rpc] Starting RPC
2022-12-19T10:43:03Z [rpc] Starting HTTP RPC server
2022-12-19T10:43:03Z Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcauth for rpcauth auth generation.
2022-12-19T10:43:03Z [http] Registering HTTP handler for / (exactmatch 1)
2022-12-19T10:43:03Z [http] Registering HTTP handler for /wallet/ (exactmatch 0)
2022-12-19T10:43:03Z [http] Starting HTTP server
2022-12-19T10:43:03Z [http] starting 4 worker threads
2022-12-19T10:43:03Z [http] Entering http event loop
2022-12-19T10:43:03Z Using wallet directory /home/user1/. bitcoin/wallets
2022-12-19T10:43:03Z init message: Verifying wallet(s)…
2022-12-19T10:43:03Z Using /16 prefix for IP bucketing
2022-12-19T10:43:03Z init message: Loading P2P addresses…
2022-12-19T10:43:04Z [addrman] CheckAddrman: new 709, tried 0, total 709 started
2022-12-19T10:43:04Z [addrman] CheckAddrman: completed (4.03ms)
2022-12-19T10:43:04Z Loaded 709 addresses from peers.dat  64ms
2022-12-19T10:43:04Z init message: Loading banlist…
2022-12-19T10:43:04Z [net] Loaded 0 banned node addresses/subnets  0ms
2022-12-19T10:43:04Z [net] setting try another outbound peer=false
2022-12-19T10:43:04Z SetNetworkActive: true
2022-12-19T10:43:04Z [estimatefee] Reading estimates: 190 buckets counting confirms up to 48 blocks
2022-12-19T10:43:04Z [estimatefee] Reading estimates: 190 buckets counting confirms up to 12 blocks
2022-12-19T10:43:04Z [estimatefee] Reading estimates: 190 buckets counting confirms up to 1008 blocks
2022-12-19T10:43:04Z Cache configuration:
2022-12-19T10:43:04Z * Using 2.0 MiB for block index database
2022-12-19T10:43:04Z * Using 8.0 MiB for chain state database
2022-12-19T10:43:04Z * Using 440.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
2022-12-19T10:43:04Z init message: Loading block index…
2022-12-19T10:43:04Z Validating signatures for all blocks.
2022-12-19T10:43:04Z Setting nMinimumChainWork=00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff
2022-12-19T10:43:04Z [leveldb] LevelDB using max_open_files=1000 (default=1000)
2022-12-19T10:43:04Z Opening LevelDB in /home/user1/. bitcoin/blocks/index
2022-12-19T10:43:04Z [leveldb:debug] Recovering log #44
2022-12-19T10:43:04Z [leveldb:debug] Delete type=0 #44
2022-12-19T10:43:04Z [leveldb:debug] Delete type=3 #43
2022-12-19T10:43:04Z Opened LevelDB successfully
2022-12-19T10:43:04Z Using obfuscation key for /home/user1/. bitcoin/blocks/index: 0000000000000000
2022-12-19T10:43:04Z LoadBlockIndexDB: last block file = 0
2022-12-19T10:43:04Z LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=1, size=293, heights=0...0, time=2009-01-03...2009-01-03)
2022-12-19T10:43:04Z Checking all blk files are present...
2022-12-19T10:43:04Z Error: Incorrect or no genesis block found. Wrong datadir for network?
2022-12-19T10:43:04Z [http] Interrupting HTTP server
2022-12-19T10:43:04Z [rpc] Interrupting HTTP RPC server
2022-12-19T10:43:04Z [rpc] Interrupting RPC
2022-12-19T10:43:04Z Shutdown: In progress...
2022-12-19T10:43:04Z [rpc] Stopping HTTP RPC server
2022-12-19T10:43:04Z [http] Unregistering HTTP handler for / (exactmatch 1)
2022-12-19T10:43:04Z [http] Unregistering HTTP handler for /wallet/ (exactmatch 0)
2022-12-19T10:43:04Z [rpc] Stopping RPC
2022-12-19T10:43:04Z [rpc] RPC stopped.
2022-12-19T10:43:04Z [http] Stopping HTTP server
2022-12-19T10:43:04Z [http] Waiting for HTTP worker threads to exit
2022-12-19T10:43:04Z [libevent:debug] event_del: 0x55ade8d64708 (fd 11), callback 0x7f981e6e5230
2022-12-19T10:43:04Z [libevent:debug] Epoll DEL(1) on fd 11 okay. Old events were 2; read change was 2 (del); write change was 0 (none); close change was 0 (none)
2022-12-19T10:43:04Z [http] Waiting for HTTP event thread to exit
2022-12-19T10:43:04Z [libevent:debug] event_del: 0x55ade8d64708 (fd 11), callback 0x7f981e6e5230
2022-12-19T10:43:04Z [libevent:debug] Epoll DEL(1) on fd 11 okay. Old events were 2; read change was 2 (del); write change was 0 (none); close change was 0 (none)
2022-12-19T10:43:04Z [http] Waiting for HTTP event thread to exit
2022-12-19T10:43:04Z [libevent:debug] epoll_dispatch: epoll_wait reports 1
2022-12-19T10:43:04Z [libevent:debug] event_active: 0x55ade8d64610 (fd 10), res 2, callback 0x7f981e6d81c0
2022-12-19T10:43:04Z [libevent:debug] event_process_active: event: 0x55ade8d64610, EV_READ   call 0x7f981e6d81c0
2022-12-19T10:43:04Z [libevent:debug] event_base_loop: no events registered.
2022-12-19T10:43:04Z [http] Exited http event loop
2022-12-19T10:43:04Z [libevent:debug] event_del: 0x55ade8d64610 (fd 10), callback 0x7f981e6d81c0
2022-12-19T10:43:04Z [libevent:debug] Epoll DEL(1) on fd 10 okay. Old events were 2; read change was 2 (del); write change was 0 (none); close change was 0 (none)
2022-12-19T10:43:04Z [libevent:debug] event_base_free_: 0 events freed
2022-12-19T10:43:04Z [http] Stopped HTTP server
2022-12-19T10:43:04Z scheduler thread exit
2022-12-19T10:43:04Z [estimatefee] Recorded 0 unconfirmed txs from mempool in 7e-07s
2022-12-19T10:43:04Z Shutdown: done



2022-12-19T12:42:12Z Bitcoin Core version v24.99.0-968f03e65c98-dirty (release build)
2022-12-19T12:42:12Z Using the 'sse4(1way),sse41(4way)' SHA256 implementation
2022-12-19T12:42:12Z Default data directory /home/user1/. bitcoin
2022-12-19T12:42:12Z Using data directory /home/user1/. bitcoin
2022-12-19T12:42:12Z Config file: /home/user1/. bitcoin/ bitcoin.conf
2022-12-19T12:42:12Z Config file arg: rpcallowip="127.0.0.1"
2022-12-19T12:42:12Z Config file arg: rpcbind=****
2022-12-19T12:42:12Z Config file arg: rpcpassword=****
2022-12-19T12:42:12Z Config file arg: rpcport="19084"
2022-12-19T12:42:12Z Config file arg: rpcuser=****
2022-12-19T12:42:12Z Config file arg: server="1"
2022-12-19T12:42:12Z Using at most 125 automatic connections (1024 file descriptors available)
2022-12-19T12:42:12Z Using 16 MiB out of 16 MiB requested for signature cache, able to store 524288 elements
2022-12-19T12:42:12Z Using 16 MiB out of 16 MiB requested for script execution cache, able to store 524288 elements
2022-12-19T12:42:12Z Script verification uses 1 additional threads
2022-12-19T12:42:12Z scheduler thread start
2022-12-19T12:42:12Z Binding RPC on address 127.0.0.1 port 19084
2022-12-19T12:42:12Z [http] creating work queue of depth 16
2022-12-19T12:42:12Z Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcauth for rpcauth auth generation.
2022-12-19T12:42:12Z [http] starting 4 worker threads
2022-12-19T12:42:12Z Using wallet directory /home/user1/. bitcoin/wallets
2022-12-19T12:42:12Z init message: Verifying wallet(s)…
2022-12-19T12:42:12Z Using /16 prefix for IP bucketing
2022-12-19T12:42:12Z init message: Loading P2P addresses…
2022-12-19T12:42:12Z Loaded 709 addresses from peers.dat  8ms
2022-12-19T12:42:12Z init message: Loading banlist…
2022-12-19T12:42:12Z SetNetworkActive: true
2022-12-19T12:42:12Z Cache configuration:
2022-12-19T12:42:12Z * Using 2.0 MiB for block index database
2022-12-19T12:42:12Z * Using 8.0 MiB for chain state database
2022-12-19T12:42:12Z * Using 440.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
2022-12-19T12:42:12Z init message: Loading block index…
2022-12-19T12:42:12Z Validating signatures for all blocks.
2022-12-19T12:42:12Z Setting nMinimumChainWork=00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff
2022-12-19T12:42:12Z Opening LevelDB in /home/user1/. bitcoin/blocks/index
2022-12-19T12:42:13Z Opened LevelDB successfully
2022-12-19T12:42:13Z Using obfuscation key for /home/user1/. bitcoin/blocks/index: 0000000000000000
2022-12-19T12:42:13Z LoadBlockIndexDB: last block file = 0
2022-12-19T12:42:13Z LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=1, size=293, heights=0...0, time=2009-01-03...2009-01-03)
2022-12-19T12:42:13Z Checking all blk files are present...
2022-12-19T12:42:13Z Error: Incorrect or no genesis block found. Wrong datadir for network?
2022-12-19T12:42:13Z Shutdown: In progress...
2022-12-19T12:42:13Z scheduler thread exit
2022-12-19T12:42:13Z Shutdown: done
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
December 19, 2022, 09:33:05 AM
#3
but apparently bitcoind stopped running for an unknown reason.
Then this should be solved first before the original question since this must be the vey reason why bitcoin-cli can't query bitcoind.

For that, provide the whole logs as instructed above.
legendary
Activity: 952
Merit: 1385
December 19, 2022, 08:53:34 AM
#2
And what logs says?

Code:
tail -f .bitcoin/debug.log

On the other hand - is .cookie file created? Did you try to connect to server using that file instead of hardcoded password?
newbie
Activity: 13
Merit: 0
December 19, 2022, 07:14:23 AM
#1
I tryied querying Bitcoin-cli (Bitcoin Core 24.0.1) in Ubuntu 20.04 WSL2 doing the following commands :

Code:
$ bitcoind -debug -daemon

Quote
Bitcoin Core starting

Code:
$bitcoin-cli -rpcuser=user -rpcpassword=pass -rpcport=19084

but for this last command I get the following error :

Quote
error: timeout on transient error: Could not connect to the server
127.0.0.1:19084

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

My bitcoin.conf file parameters are :

Code:
rpcuser=user
rpcpassword=pass
rpcallowip=127.0.0.1
rpcport=19084
server=1

I then tried the following command in order to check if bitcoind still running in the background :
Code:
$ps -aux

Quote
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0    896   532 ?        Sl   05:10   0:00 /init
root       212  0.0  0.0    896    88 ?        Ss   07:22   0:00 /init
root       213  0.0  0.0    896    88 ?        R    07:22   0:00 /init
username   214  0.0  0.1  10288  5548 pts/0    Ss   07:22   0:02 -bash
root       248  0.0  0.0    896    88 ?        Ss   07:30   0:00 /init
root       249  0.0  0.0    896    88 ?        S    07:30   0:00 /init
username   250  0.0  0.1  10176  5404 pts/1    Ss   07:30   0:00 -bash
username   296  0.0  0.3  23572  9756 pts/1    S+   07:33   0:01 vi bitcoin.conf
root       367  0.0  0.0    896    88 ?        Ss   09:26   0:00 /init
root       368  0.0  0.0    896    88 ?        S    09:26   0:00 /init
username   369  0.0  0.1  10176  5572 pts/2    Ss+  09:26   0:01 -bash
username  1035  0.0  0.1  10856  3460 pts/0    R+   10:51   0:00 ps -aux


but apparently bitcoind stopped running for an unknown reason.
Jump to: