ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.84k stars 901 forks source link

lightning-cli: Connecting to 'lightning-rpc': Connection refused #7054

Closed eliaspfeffer closed 8 months ago

eliaspfeffer commented 8 months ago

Issue and Steps to Reproduce

When attempting to use lightning-cli getinfo, I get this:

satoshi@lightning:~$ lightning-cli getinfo

lightning-cli: Connecting to 'lightning-rpc': Connection refused

Meanwhile lightning-cli runs without any problems. Meaning it shows me the typical commands overview.

Software versions used:

Bitcoin Core RPC client version v25.0.0 C-Lightning: v23.11.2-modded (Have self-compiled C-Lightning like in this tutorial: CLN 1 - Setup & Backup )

Steps to reproduce:

  1. Have made everything run once (was able to run lightning-cli getinfo etc).
  2. Turned off my machine for a month
  3. Turned back on my machine after a month
  4. Waited for Bitcoin Core to Sync
  5. Started Lightningd
  6. Started Lightning-cli getinfo --> Getting the error. See Log entry down below:
  7. I'm not sure anymore, if I have a full node or not (Have had one, but it got corrupted and didn't want to download it again, so not sure if its running as a full node or not, currently).
  8. Tor is running, but not used duo to Tor not working see Tor down below

Configuration Files

~/.bitcoin/bitcoin.conf

server=1
rpcuser=user
rpcpassword=pass
rpcbind=127.0.0.1
rpcport=8332

~/.lightning/config

alias=greatnode42
rgb=000000

daemon
network=bitcoin
log-file=/home/user/.lightning/lightning.log
log-level=debug

fee-base=1000
fee-per-satoshi=1
min-capacity-sat=5000000

large-channels
funding-confirms=2
autocleaninvoice-cycle=86400
autocleaninvoice-expired-by=86400

bitcoin-rpcuser=user
bitcoin-rpcpassword=pass
bitcoin-rpcconnect=127.0.0.1
bitcoin-rpcport=8332

Log File

2024-02-08T11:14:36.697Z INFO    lightningd: v23.11.2-modded
2024-02-08T11:14:37.962Z DEBUG   lightningd: Opened log file /home/satoshi/.lightning/lightning.log
2024-02-08T11:14:37.972Z DEBUG   plugin-manager: started(8773) /usr/local/libexec/c-lightning/plugins/autoclean
2024-02-08T11:14:37.982Z DEBUG   plugin-manager: started(8774) /usr/local/libexec/c-lightning/plugins/chanbackup
2024-02-08T11:14:37.991Z DEBUG   plugin-manager: started(8775) /usr/local/libexec/c-lightning/plugins/bcli
2024-02-08T11:14:38.001Z DEBUG   plugin-manager: started(8776) /usr/local/libexec/c-lightning/plugins/commando
2024-02-08T11:14:38.010Z DEBUG   plugin-manager: started(8777) /usr/local/libexec/c-lightning/plugins/fetchinvoice
2024-02-08T11:14:38.020Z DEBUG   plugin-manager: started(8778) /usr/local/libexec/c-lightning/plugins/funder
2024-02-08T11:14:38.029Z DEBUG   plugin-manager: started(8779) /usr/local/libexec/c-lightning/plugins/topology
2024-02-08T11:14:38.039Z DEBUG   plugin-manager: started(8780) /usr/local/libexec/c-lightning/plugins/keysend
2024-02-08T11:14:38.048Z DEBUG   plugin-manager: started(8781) /usr/local/libexec/c-lightning/plugins/offers
2024-02-08T11:14:38.057Z DEBUG   plugin-manager: started(8782) /usr/local/libexec/c-lightning/plugins/pay
2024-02-08T11:14:38.067Z DEBUG   plugin-manager: started(8783) /usr/local/libexec/c-lightning/plugins/txprepare
2024-02-08T11:14:38.076Z DEBUG   plugin-manager: started(8784) /usr/local/libexec/c-lightning/plugins/cln-renepay
2024-02-08T11:14:38.086Z DEBUG   plugin-manager: started(8785) /usr/local/libexec/c-lightning/plugins/spenderp
2024-02-08T11:14:38.096Z DEBUG   plugin-manager: started(8786) /usr/local/libexec/c-lightning/plugins/sql
2024-02-08T11:14:38.105Z DEBUG   plugin-manager: started(8787) /usr/local/libexec/c-lightning/plugins/cln-grpc
2024-02-08T11:14:38.115Z DEBUG   plugin-manager: started(8789) /usr/local/libexec/c-lightning/plugins/bookkeeper
2024-02-08T11:14:38.130Z DEBUG   plugin-manager: started(8790) /usr/local/libexec/c-lightning/plugins/clnrest/clnrest.py
2024-02-08T11:14:39.174Z DEBUG   lightningd: io_break: check_plugins_manifests
2024-02-08T11:14:39.174Z DEBUG   lightningd: io_loop_with_timers: plugins_init
2024-02-08T11:14:39.176Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_channeld
2024-02-08T11:14:39.181Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_closingd
2024-02-08T11:14:39.186Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_connectd
2024-02-08T11:14:39.191Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_gossipd
2024-02-08T11:14:39.196Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_hsmd
2024-02-08T11:14:39.201Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_onchaind
2024-02-08T11:14:39.205Z DEBUG   lightningd: testing /usr/local/libexec/c-lightning/lightning_openingd
2024-02-08T11:14:39.209Z DEBUG   hsmd: pid 8798, msgfd 53
2024-02-08T11:14:39.215Z DEBUG   hsmd: capability +WIRE_HSMD_CHECK_PUBKEY
2024-02-08T11:14:39.215Z DEBUG   hsmd: capability +WIRE_HSMD_SIGN_ANY_DELAYED_PAYMENT_TO_US
2024-02-08T11:14:39.215Z DEBUG   hsmd: capability +WIRE_HSMD_SIGN_ANCHORSPEND
2024-02-08T11:14:39.215Z DEBUG   hsmd: capability +WIRE_HSMD_SIGN_HTLC_TX_MINGLE
2024-02-08T11:14:39.215Z DEBUG   hsmd: capability +WIRE_HSMD_SIGN_SPLICE_TX
2024-02-08T11:14:39.215Z DEBUG   hsmd: capability +WIRE_HSMD_CHECK_OUTPOINT
2024-02-08T11:14:39.872Z DEBUG   connectd: pid 8799, msgfd 57
2024-02-08T11:14:39.872Z DEBUG   hsmd: Client: Received message 27 from client
2024-02-08T11:14:39.872Z DEBUG   hsmd: Client: Received message 27 from client
2024-02-08T11:14:39.872Z DEBUG   hsmd: new_client: 0
2024-02-08T11:14:39.892Z DEBUG   connectd: Created listener on [::]:9735
2024-02-08T11:14:39.892Z DEBUG   connectd: Failed to connect 10 socket: Network is unreachable
2024-02-08T11:14:39.892Z DEBUG   connectd: Created listener on 0.0.0.0:9735
2024-02-08T11:14:39.892Z DEBUG   connectd: REPLY WIRE_CONNECTD_INIT_REPLY with 0 fds
2024-02-08T11:14:39.892Z DEBUG   lightningd: io_break: connect_init_done
2024-02-08T11:14:39.892Z DEBUG   lightningd: io_loop: connectd_init
2024-02-08T11:14:39.930Z INFO    plugin-bcli: bitcoin-cli initialized and connected to bitcoind.
2024-02-08T11:14:39.930Z DEBUG   lightningd: io_break: plugin_config_cb
2024-02-08T11:14:39.930Z DEBUG   lightningd: io_loop_with_timers: config_plugin
2024-02-08T11:14:39.930Z DEBUG   lightningd: All Bitcoin plugin commands registered
2024-02-08T11:14:40.125Z UNUSUAL plugin-bcli: bitcoin-cli -rpcconnect=127.0.0.1 -rpcport=8332 -rpcuser=... -stdinrpcpass getblock 0000000000000000000217f1453a5a4550689f70a5280c1dd413821d921f429c 0 exited with status 1
2024-02-08T11:14:40.126Z DEBUG   plugin-clnrest.py: Notification: {'warning': {'level': 'warn', 'time': '1707390880.125604527', 'timestamp': '2024-02-08T11:14:40.125Z', 'source': 'plugin-bcli', 'log': 'bitcoin-cli -rpcconnect=127.0.0.1 -rpcport=8332 -rpcuser=... -stdinrpcpass getblock 0000000000000000000217f1453a5a4550689f70a5280c1dd413821d921f429c 0 exited with status 1'}}
2024-02-08T11:14:41.129Z UNUSUAL plugin-bcli: bitcoin-cli -rpcconnect=127.0.0.1 -rpcport=8332 -rpcuser=... -stdinrpcpass getblock 0000000000000000000217f1453a5a4550689f70a5280c1dd413821d921f429c 0 exited with status 1
2024-02-08T11:14:41.129Z DEBUG   plugin-clnrest.py: Notification: {'warning': {'level': 'warn', 'time': '1707390881.129010756', 'timestamp': '2024-02-08T11:14:41.129Z', 'source': 'plugin-bcli', 'log': 'bitcoin-cli -rpcconnect=127.0.0.1 -rpcport=8332 -rpcuser=... -stdinrpcpass getblock 0000000000000000000217f1453a5a4550689f70a5280c1dd413821d921f429c 0 exited with status 1'}}
2024-02-08T11:14:42.132Z UNUSUAL plugin-bcli: bitcoin-cli -rpcconnect=127.0.0.1 -rpcport=8332 -rpcuser=... -stdinrpcpass getblock 0000000000000000000217f1453a5a4550689f70a5280c1dd413821d921f429c 0 exited with status 1
.
.
.
2024-02-08T12:08:56.375Z DEBUG   plugin-clnrest.py: Notification: {'warning': {'level': 'warn', 'time': '1707394136.374936437', 'timestamp': '2024-02-08T12:08:56.374Z', 'source': 'plugin-bcli', 'log': 'bitcoin-cli -rpcconnect=127.0.0.1 -rpcport=8332 -rpcuser=... -stdinrpcpass getblock 0000000000000000000217f1453a5a4550689f70a5280c1dd413821d921f429c 0 exited with status 1'}}
satoshi@lightning:~$ ps waux | grep lightningd
loskud-+    8750  0.0  2.0 345300 331008 pts/0   S+   12:14   0:00 lightningd
loskud-+    8772  0.0  0.1  46300 29084 pts/0    S+   12:14   0:03 lightningd
loskud-+  132872  0.0  0.0   9608  2560 pts/6    S+   14:58   0:00 grep --color=auto lightningd
satoshi@lightning:~$ lightning-cli getinfo
lightning-cli: Connecting to 'lightning-rpc': Connection refused

Additional Context

Steps Taken

  1. Verified firewall settings to ensure port accessibility.
  2. Confirmed Tor configuration and ensured that Tor service is running.
  3. Checked Tor logs for any errors or warnings.
  4. Restarted Tor service and attempted to reconnect.
  5. Tested Tor Browser to ensure network connectivity.

System Information

Tor Status:

satoshi@lightning:~$ sudo systemctl status tor
... 
● tor.service - Anonymizing overlay network for TCP (multi-instance-master)
     Loaded: loaded (/lib/systemd/system/tor.service; enabled; vendor preset: e>
     Active: active (exited) since Thu 2024-02-08 11:52:30 CET; 1h 6min ago
    Process: 789 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 789 (code=exited, status=0/SUCCESS)
        CPU: 1ms

Feb 08 11:52:30 bybnut-4hadjU-hesdym systemd[1]: Starting Anonymizing overlay n>
Feb 08 11:52:30 bybnut-4hadjU-hesdym systemd[1]: Finished Anonymizing overlay n>

satoshi@lightning:~$ torsocks curl https://check.torproject.org/api/ip
{"IsTor":false,"IP":"..."}
eliaspfeffer commented 8 months ago

I think I've figured it out.

As I have a pruned node, which you can figure out via this: bitcoin-cli getblockchaininfo | grep -E 'blocks|pruned' , lightning was looking for a very old block (see the log, mentioned above: Block ID 0000000000000000000217f1453a5a4550689f70a5280c1dd413821d921f429c.)

But because my Bitcoin Node is pruned, it doesnt have that. So I've had two options:

Give Bitcoin Core more blocks

and before that figuring out how many blocks I need (=> look at www.mempool.space, enter the block ID, look at the blockheight, compare that with the current blockheight, enter the difference + a bit more).

Resetting my node

Attention: if you do this, you will loose all your eventually still in your node existing funds! How to do that: Stop lightning, go to the .lightning folder, cut out everything (dont delete it, but move it somewhere else if you need to get access to your old node one day). Restart lightning.

Did the second option. Now its running again.

Could be a possible fix in future:

Check which BlockID is missing, figure out the difference, download the missing difference (, delete the difference later again?)