'Failed to start tor@default.service' restarting tor services

Hi onions,
I’m trying to run a middle relay but I’m having an error running the service.

I have configured the torrc file as follow:

# Tor settings
ORPort 443
SocksPort 0
ControlPort 9051
CookieAuthentication 1
RunAsDaemon 1
DataDirectory /home/local/path

# Contact config 
Nickname Aleff
ContactInfo My Name <my_email>

# Exit policy
ExitRelay 0
ExitPolicy reject *:* # no exits allowed

And when i try to run systemctl start tor@default.service i receive the following error line:

Job for tor@default.service failed because the control process exited with error code.
See "systemctl status tor@default.service" and "journalctl -xeu tor@default.service" for details.

Output of systemctl status tor@default.service:

× tor@default.service - Anonymizing overlay network for TCP
     Loaded: loaded (/lib/systemd/system/tor@default.service; enabled-runtime; preset: enabled)
     Active: failed (Result: exit-code) since Mon 2023-05-08 12:13:27 CEST; 2min 17s ago
   Duration: 6min 54.630s
    Process: 18590 ExecStartPre=/usr/bin/install -Z -m 02755 -o debian-tor -g debian-tor -d /run/tor (code=exited, status=0/SUCCESS)
    Process: 18591 ExecStartPre=/usr/bin/tor --defaults-torrc /usr/share/tor/tor-service-defaults-torrc -f /etc/tor/torrc --RunAsDaemon 0 --verify-config (code=exited, status=1/FAILURE)
        CPU: 51ms

May 08 12:13:27 ThinkPad systemd[1]: tor@default.service: Scheduled restart job, restart counter is at 5.
May 08 12:13:27 ThinkPad systemd[1]: Stopped tor@default.service - Anonymizing overlay network for TCP.
May 08 12:13:27 ThinkPad systemd[1]: tor@default.service: Start request repeated too quickly.
May 08 12:13:27 ThinkPad systemd[1]: tor@default.service: Failed with result 'exit-code'.
May 08 12:13:27 ThinkPad systemd[1]: Failed to start tor@default.service - Anonymizing overlay network for TCP.

Thanks for the help <3

If you don‘t want to set a SocksPort just comment ist out.
Also, make sure the Directory /home/local/path exists ans is owned by User debian-tor with

sudo chown debian-tor:debian-tor /home/local/path

Try again and Check /var/log/syslog
There should be more information what exactly went wrong.

Ok i think that you have right, the problem should be a permission based problem becouse in the syslog file i found this one line 2023-05-09T12:40:16.248479+02:00 ThinkPad tor[29145]: May 09 12:40:16.248 [warn] Directory /home/local/path cannot be read: Permission denied but i seen that i have two tor services:

  • tor.service with the following status:
Loaded: loaded (/lib/systemd/system/tor.service; enabled; preset: enabled)
Active: active (exited) since Tue 2023-05-09 12:46:54 CEST; 3min 56s ago
  • tor@default.service with the following status:
Loaded: loaded (/lib/systemd/system/tor@default.service; enabled-runtime; 
Active: failed (Result: exit-code) since Tue 2023-05-09 12:47:15 CEST; 2min 5>

so the problem can be that i have two tor service and the second one can’t be runned becouse an another one is active, in this case (if it should be a problem for you too) how can i reduce the services to one?

And, for the service /lib/systemd/system/tor.service that is the active service, where can i find the relative torrc file to modify the configuration?

As I understad it, tor.service is the master for all tor-instances.
It is normal and required that it is running.

tor@default.service is your default tor-instance for one relay.
(there can be more than one, up to 4 per IP)

As your problem seems to be the permissions for the data directory,
you can try to not set a DataDirecoty in your torrc config.
Tor will default to

/var/lib/tor

on Debian and Ubuntu.
You do not need to create this folder.