<p>the problem is in your call of <code>charged</code> there you are passing the argument <code>--ln-path ~/.lightning</code> assuming that you run lightning in your home directory thus you have to set <code>ln-path</code> to <code>/tmp/l1-regtest/</code>. </p>

<p>Now you say that this also did not work. So before I give you a solution let me explain what is actually going on. <code>charged</code> talkes to <code>lightningd</code> via an rpc-interface on an UNIX Domain socket. In older versions of <code>lightningd</code> there was a file called <code>lightning-rpc</code> in the folder that you specified as <code>lightning-dir</code> however <code>lightningd</code> has switched its API recently to to have subdirectories in <code>lightning-dir</code> for mainnet, testnet and regtest. (the reason was that in particular in the default directory people wanted to have different configs for mainnet, testnet and regtest) </p>

<p>Thus I assume that you will find <code>lightning-rpc</code> when you do <code>ls /tmp/l1-regtest/regtest</code> which means that you should pass the <code>tmp/l1-regtest/regtest</code> in <code>--ln-path</code> when you call <code>charged</code>. If that is not the case I would have to see another error message.</p>

CC BY-SA 4.0
2020-05-19T19:30:42.027Z
It works! thank you and thanks for making all those yt videos!
kschieck
CC BY-SA 4.0
2020-05-19T19:17:42.030Z
2020-05-19T19:17:42.030Z
Rene Pickhardt
<p>I'm trying to run lighting-charge (<a href="https://github.com/ElementsProject/lightning-charge" rel="nofollow noreferrer">https://github.com/ElementsProject/lightning-charge</a>) on top of one of my 2 lightning (<a href="https://github.com/ElementsProject/lightning" rel="nofollow noreferrer">https://github.com/ElementsProject/lightning</a>) instances. I am running 2 nodes using the script here: <code>lightning/contrib/startup_regtest.sh</code>. This file will start a bitcoin instance as well as 2 lightning nodes (<code>/tmp/l1-regtest</code>, <code>/tmp/l2-regtest</code>)</p>

<p>I then tried to run lightning-charge with:</p>

<pre><code>$ NETWORK=regtest charged --api-token super_secret_1 --ln-path ~/.lightning --db-path ~/charge1.db --port 9112
</code></pre>

<p>Which gives me this error:</p>

<pre><code>Lightning client connection error { Error: connect ECONNREFUSED ~/.lightning
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '~/.lightning' }
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED ~/.lightning
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)
</code></pre>

<p>I've also tried running it with <code>ln-path</code> set to <code>/tmp/l1-regtest/</code></p>

<p>with <code>ps aux</code> I can see lightning is running with this command:</p>

<pre><code>~/git/lightning/lightningd/lightningd --lightning-dir=/tmp/l1-regtest
and
~/git/lightning/lightningd/lightningd --lightning-dir=/tmp/l2-regtest
</code></pre>

<p>Does anyone know how to get <code>lightning-charge</code> to connect to my regtest lightning node?</p>

<p>There are instructions on how to do this in docker in the readme file (<a href="https://github.com/ElementsProject/lightning-charge/blob/master/README.md" rel="nofollow noreferrer">https://github.com/ElementsProject/lightning-charge/blob/master/README.md</a>), but it doesn't seem to work outside of docker.</p>

CC BY-SA 4.0
2020-05-19T17:23:39.430Z
Does lightning charge connect via a port to lightning? I just realized that the regtest lightning doesn't use the default port 9735 but actually uses 6060 and 9090
kschieck
CC BY-SA 4.0
2020-05-19T17:28:10.110Z
I guess I could just run it on docker and mount the lightning and Bitcoin dirs. It does explain how to do that in the readme. It's pretty complicated though so I was hoping to avoid using docker. I'll report back after I've tried that.
kschieck
<lightning-network><regtest><lightning-network-daemon><core-lightning><lightning-nodes>
Run lightning-charge on c-lightning regtest
kschieck
# Run lightning-charge on c-lightning regtest

(Asked by: username_0 on 2020-05-19)

I'm trying to run lighting-charge (<https://github.com/ElementsProject/lightning-charge>) on top of one of my 2 lightning (<https://github.com/ElementsProject/lightning>) instances. I am running 2 nodes using the script here: `lightning/contrib/startup_regtest.sh`. This file will start a bitcoin instance as well as 2 lightning nodes (`/tmp/l1-regtest`, `/tmp/l2-regtest`)

I then tried to run lightning-charge with:

```
$ NETWORK=regtest charged --api-token super_secret_1 --ln-path ~/.lightning --db-path ~/charge1.db --port 9112

```

Which gives me this error:

```
Lightning client connection error { Error: connect ECONNREFUSED ~/.lightning
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '~/.lightning' }
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED ~/.lightning
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)

```

I've also tried running it with `ln-path` set to `/tmp/l1-regtest/`

with `ps aux` I can see lightning is running with this command:

```
~/git/lightning/lightningd/lightningd --lightning-dir=/tmp/l1-regtest
and
~/git/lightning/lightningd/lightningd --lightning-dir=/tmp/l2-regtest

```

Does anyone know how to get `lightning-charge` to connect to my regtest lightning node?

There are instructions on how to do this in docker in the readme file (<https://github.com/ElementsProject/lightning-charge/blob/master/README.md>), but it doesn't seem to work outside of docker.

**Tags:** lightning-network, regtest, lightning-network-daemon, core-lightning, lightning-nodes

> **Comments:**
> **username_0**: Does lightning charge connect via a port to lightning? I just realized that the regtest lightning doesn't use the default port 9735 but actually uses 6060 and 9090  
> **username_0**: I guess I could just run it on docker and mount the lightning and Bitcoin dirs. It does explain how to do that in the readme. It's pretty complicated though so I was hoping to avoid using docker. I'll report back after I've tried that.  

---

## 1 answers

### Answer by username_1 on 2020-05-19. Score: 2 | Accepted answer

the problem is in your call of `charged` there you are passing the argument `--ln-path ~/.lightning` assuming that you run lightning in your home directory thus you have to set `ln-path` to `/tmp/l1-regtest/`.

Now you say that this also did not work. So before I give you a solution let me explain what is actually going on. `charged` talkes to `lightningd` via an rpc-interface on an UNIX Domain socket. In older versions of `lightningd` there was a file called `lightning-rpc` in the folder that you specified as `lightning-dir` however `lightningd` has switched its API recently to to have subdirectories in `lightning-dir` for mainnet, testnet and regtest. (the reason was that in particular in the default directory people wanted to have different configs for mainnet, testnet and regtest)

Thus I assume that you will find `lightning-rpc` when you do `ls /tmp/l1-regtest/regtest` which means that you should pass the `tmp/l1-regtest/regtest` in `--ln-path` when you call `charged`. If that is not the case I would have to see another error message.

> **Comments:**
> **username_0**: It works! thank you and thanks for making all those yt videos!  

---

