<p>The <code>statictor</code> method uses a control port (9051 by default) and authentication to allow CLN to set up the .onion address and control Tor so you don't have to do it manually. I haven't used <code>statictor</code> myself but I'm pretty sure the following will get you up and running.</p>
<p>There are 2 authentication methods: cookie or password. It looks like you already have it partially set up to use password authentication, so we'll go with that.</p>
<p>The first thing you need to do is choose a password if you have not already chosen one. It can be any password you want. Let's say we've chosen the fake password <code>xyzxyzxyz</code>. Then we would run the following command on the command line. (You will want to use the real password you chose instead of this fake one.)</p>
<pre><code>tor --hash-password xyzxyzxyz
</code></pre>
<p>That will return a hash of your password that looks something like this:</p>
<pre><code>16:0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789
</code></pre>
<p>That hash needs to be added to <code>torrc</code> so that Tor can authenticate your node. (That's why your getting that error message saying <code>Password did not match HashedControlPassword value from configuration</code>.) In your <code>torrc</code> file you'll need to make sure that <code>HashedControlPassword</code> is set to the hash returned by the command we just ran. You can copy and paste it into <code>torrc</code> and it will look similar to this example.</p>
<pre><code>HashedControlPassword 16:0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789
</code></pre>
<p>Restart Tor.</p>
<p>Now that Tor knows the hash of your password, you have to let CLN know what the actual password is by adding the following line to <code>CLN's config file</code>. (CLN's config file stores your Tor password in plain text, so the file should be kept as secure as possible.) Using the fake password we chose above, it would look like this. You'll need to use your real password, of course.</p>
<pre><code>tor-service-password=xyzxyzxyz
</code></pre>
<p>Combined with the settings that you already have in your two config files, adding the settings and making the other changes mentioned above should solve your problem.</p>
<p>You can read more details about using <code>statictor</code> and about cookie authentication (the other authentication method) in the <a href="https://lightning.readthedocs.io/TOR.html#letting-core-lightning-control-tor" rel="nofollow noreferrer">Letting Core Lightning Control Tor</a> section of the CLN documentation. You can also find details about the settings and commands supported by your specific version of Tor by running <code>man torrc</code> or <code>man tor</code>.</p>

CC BY-SA 4.0
2022-12-24T03:14:12.917Z
thanks for the info it has been very useful and I can move onto the next problem
user209474
CC BY-SA 4.0
2022-12-22T14:40:23.880Z
2022-12-22T14:40:23.880Z
Zephyrus
<p>Suddenly started getting this error, where should I look to try and fix it? Tor version 0.4.7.10 Tor compiled with GCC version 12.2.0
and lightning v0.11.2</p>
<p><code>e: lightning_connectd: Connecting stream socket to Tor service: Connection refused</code><br />
<code>lightningd: connectd failed (exit status 1), exiting.</code></p>
<p>tor.service - Anonymizing overlay network for TCP (multi-instance-master) Loaded: loaded (/lib/systemd/system/tor.service; enabled; preset: enabled) Active: active (exited) since Mon 2022-12-19 11:59:13 AEDT; 8h ago Process: 15294 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 15294 (code=exited, status=0/SUCCESS) CPU: 1ms Dec 19 11:59:13 Sophia systemd[1]: Starting Anonymizing overlay network for TCP (multi-instance-master)... Dec 19 11:59:13 Sophia systemd[1]: Finished Anonymizing overlay network for TCP (multi-instance-master). Is tor working??? –
user209474</p>
<p>My debug.log file does not open when I just enter tor.   I get the message  Couldn't open file for 'Log debug file var/log/tor/debug.log': No such file or directory
debug.log has my user name as the group in file properties. How do I correct this problem. Appreciate any ideas.</p>
<p>torrc config:
Log debug file /var/log/tor/debug.log
ControlPort 9051
HashedControlPassword16:XXXXX
ExitPolicy reject <em>:</em> # no exits allowed</p>
<p>and the ln config;</p>
<p>proxy=127.0.0.1:9050
bind-addr=127.0.0.1:9735
addr=statictor:127.0.0.1:9051
always-use-proxy=true</p>
<p>wallet=sqlite3:///home/rick/.lightning/bitcoin/lightningd.sqlite3:/home/rick/Documents/backup/lightningd.sqlite3</p>
<p>and finally when I now try to start LN I get:
Tor returned '515 Authentication failed: Password did not match HashedControlPassword value from configuration</p>
<p>tor-service-password=yourpassword</p>

CC BY-SA 4.0
2022-12-18T10:50:59.903Z
This sounds like your local Tor daemon is not running. Depending on your distribution the following might work: `sudo systemctl status tor`. If it shows `disabled` or some other error code, then you need to address that issue or simply restart it.
cdecker
CC BY-SA 4.0
2022-12-18T14:24:18.610Z
@cdecker: I think that sounds like an answer. Could you post it as an answer instead please?
Murch
CC BY-SA 4.0
2022-12-19T09:29:53.923Z
@Murch not an answer, connectivity problem still exists
user209474
CC BY-SA 4.0
2022-12-19T11:25:23.677Z
@user209474 Does the tor user have permission to open its debug.log file, and access the rest of its files? You can test this by running `sudo -u debian-tor ls -l /var/log/tor/`, although the tor username could be different on your system.
Zephyrus
CC BY-SA 4.0
2022-12-20T01:28:49.693Z
@Zephyrus the tor user name is different, the result was as follows:                                -rw-r--r-- for debug.log.
user209474
CC BY-SA 4.0
2022-12-20T12:58:07.040Z
@user209474 Can you add the version numbers for your installations of `tor` and `cln` to your original question, and also the contents of your `torrc` file and parameters you are passing to `cln`, either from a config file or on the command line? (Change username/password info to something like `xxxxxxxx` before posting these files.) The error you are getting only happens when using either `autotor` or `statictor` methods for connecting to tor. These methods require cln to use a password to access tor and I'm wondering if that could be the cause of this problem.
Zephyrus
CC BY-SA 4.0
2022-12-22T08:28:14.730Z
I created a new password. I dont know where to find the 'value in the configuration'
user209474
<lightning-network><core-lightning><tor>
CLN having issues connecting to Tor service
user209474
# CLN having issues connecting to Tor service

(Asked by: username_0 on 2022-12-18)

Suddenly started getting this error, where should I look to try and fix it? Tor version 0.4.7.10 Tor compiled with GCC version 12.2.0
and lightning v0.11.2

`e: lightning_connectd: Connecting stream socket to Tor service: Connection refused`  
`lightningd: connectd failed (exit status 1), exiting.`

tor.service - Anonymizing overlay network for TCP (multi-instance-master) Loaded: loaded (/lib/systemd/system/tor.service; enabled; preset: enabled) Active: active (exited) since Mon 2022-12-19 11:59:13 AEDT; 8h ago Process: 15294 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 15294 (code=exited, status=0/SUCCESS) CPU: 1ms Dec 19 11:59:13 Sophia systemd[1]: Starting Anonymizing overlay network for TCP (multi-instance-master)... Dec 19 11:59:13 Sophia systemd[1]: Finished Anonymizing overlay network for TCP (multi-instance-master). Is tor working??? –
username_0

My debug.log file does not open when I just enter tor. I get the message Couldn't open file for 'Log debug file var/log/tor/debug.log': No such file or directory
debug.log has my user name as the group in file properties. How do I correct this problem. Appreciate any ideas.

torrc config:
Log debug file /var/log/tor/debug.log
ControlPort 9051
HashedControlPassword16:XXXXX
ExitPolicy reject *:* # no exits allowed

and the ln config;

proxy=127.0.0.1:9050
bind-addr=127.0.0.1:9735
addr=statictor:127.0.0.1:9051
always-use-proxy=true

wallet=sqlite3:///home/rick/.lightning/bitcoin/lightningd.sqlite3:/home/rick/Documents/backup/lightningd.sqlite3

and finally when I now try to start LN I get:
Tor returned '515 Authentication failed: Password did not match HashedControlPassword value from configuration

tor-service-password=yourpassword

**Tags:** lightning-network, core-lightning, tor

> **Comments:**
> **username_1**: This sounds like your local Tor daemon is not running. Depending on your distribution the following might work: `sudo systemctl status tor`. If it shows `disabled` or some other error code, then you need to address that issue or simply restart it.  
> **username_2**: @username_1: I think that sounds like an answer. Could you post it as an answer instead please?  
> **username_0**: @username_2 not an answer, connectivity problem still exists  
> **username_3**: @username_0 Does the tor user have permission to open its debug.log file, and access the rest of its files? You can test this by running `sudo -u debian-tor ls -l /var/log/tor/`, although the tor username could be different on your system.  
> **username_0**: @username_3 the tor user name is different, the result was as follows:                                -rw-r--r-- for debug.log.  
> **username_3**: @username_0 Can you add the version numbers for your installations of `tor` and `cln` to your original question, and also the contents of your `torrc` file and parameters you are passing to `cln`, either from a config file or on the command line? (Change username/password info to something like `xxxxxxxx` before posting these files.) The error you are getting only happens when using either `autotor` or `statictor` methods for connecting to tor. These methods require cln to use a password to access tor and I'm wondering if that could be the cause of this problem.  
> **username_0**: I created a new password. I dont know where to find the 'value in the configuration'  

---

## 1 answers

### Answer by username_3 on 2022-12-22. Score: 0 | Accepted answer

The `statictor` method uses a control port (9051 by default) and authentication to allow CLN to set up the .onion address and control Tor so you don't have to do it manually. I haven't used `statictor` myself but I'm pretty sure the following will get you up and running.

There are 2 authentication methods: cookie or password. It looks like you already have it partially set up to use password authentication, so we'll go with that.

The first thing you need to do is choose a password if you have not already chosen one. It can be any password you want. Let's say we've chosen the fake password `xyzxyzxyz`. Then we would run the following command on the command line. (You will want to use the real password you chose instead of this fake one.)

```
tor --hash-password xyzxyzxyz

```

That will return a hash of your password that looks something like this:

```
16:0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789

```

That hash needs to be added to `torrc` so that Tor can authenticate your node. (That's why your getting that error message saying `Password did not match HashedControlPassword value from configuration`.) In your `torrc` file you'll need to make sure that `HashedControlPassword` is set to the hash returned by the command we just ran. You can copy and paste it into `torrc` and it will look similar to this example.

```
HashedControlPassword 16:0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789

```

Restart Tor.

Now that Tor knows the hash of your password, you have to let CLN know what the actual password is by adding the following line to `CLN's config file`. (CLN's config file stores your Tor password in plain text, so the file should be kept as secure as possible.) Using the fake password we chose above, it would look like this. You'll need to use your real password, of course.

```
tor-service-password=xyzxyzxyz

```

Combined with the settings that you already have in your two config files, adding the settings and making the other changes mentioned above should solve your problem.

You can read more details about using `statictor` and about cookie authentication (the other authentication method) in the [Letting Core Lightning Control Tor](https://lightning.readthedocs.io/TOR.html#letting-core-lightning-control-tor) section of the CLN documentation. You can also find details about the settings and commands supported by your specific version of Tor by running `man torrc` or `man tor`.

> **Comments:**
> **username_0**: thanks for the info it has been very useful and I can move onto the next problem  

---

