restic / rest-server

Rest Server is a high performance HTTP server that implements restic's REST backend API.
BSD 2-Clause "Simplified" License
943 stars 140 forks source link

systemd: address family not supported by protocol #293

Closed fluidum closed 1 month ago

fluidum commented 1 month ago

Output of rest-server --version

rest-server version rest-server 0.12.1 compiled with go1.20.5 on linux/amd64

How did you run rest-server exactly?

/usr/local/bin/rest-server --path /mnt/ --private-repos --append-only

What backend/server/service did you use to store the repository?

local

Expected behavior

● rest-server.service - Rest Server
     Loaded: loaded (/etc/systemd/system/rest-server.service; disabled; preset: enabled)
     Active: active (running) since Fri 2024-07-19 20:23:41 EEST; 1s ago
TriggeredBy: ● rest-server.socket
   Main PID: 26722 (rest-server)
      Tasks: 8 (limit: 9304)
     Memory: 3.1M
        CPU: 57ms
     CGroup: /system.slice/rest-server.service
             └─26722 /usr/local/bin/rest-server --path /mnt/<dummy> --private-repos --append-only

Jul 19 20:23:41 server1 systemd[1]: Started rest-server.service - Rest Server.
Jul 19 20:23:41 server1 rest-server[26722]: Data directory: /mnt/<dummy>/<dummy>
Jul 19 20:23:41 server1 rest-server[26722]: Authentication enabled
Jul 19 20:23:41 server1 rest-server[26722]: Loaded htpasswd file /mnt/<dummy>/.htpasswd
Jul 19 20:23:41 server1 rest-server[26722]: Private repositories enabled
Jul 19 20:23:41 server1 rest-server[26722]: start server on :8000

Actual behavior

 systemctl status rest-server.service
● rest-server.service - Rest Server
     Loaded: loaded (/etc/systemd/system/rest-server.service; disabled; preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2024-07-19 20:14:54 EEST; 2s ago
TriggeredBy: ● rest-server.socket
    Process: 25243 ExecStart=/usr/local/bin/rest-server --path /mnt/dummy --private-repos --append-only (code=exited, status=1/FAILURE)
   Main PID: 25243 (code=exited, status=1/FAILURE)
        CPU: 54ms

journalctl -u rest-server -f

Jul 19 20:23:29 server1 rest-server[26652]: Data directory: /mnt/<dummy>/<dummy>
Jul 19 20:23:29 server1 rest-server[26652]: Authentication enabled
Jul 19 20:23:29 server1 rest-server[26652]: Loaded htpasswd file /mnt/<dummy>/.htpasswd
Jul 19 20:23:29 server1 rest-server[26652]: Private repositories enabled
Jul 19 20:23:29 server1 rest-server[26652]: error: unable to listen: listen on :8000 failed: listen tcp :8000: socket: address family not supported by protocol
Jul 19 20:23:29 server1 systemd[1]: rest-server.service: Main process exited, code=exited, status=1/FAILURE
Jul 19 20:23:29 server1 systemd[1]: rest-server.service: Failed with result 'exit-code'.
Jul 19 20:23:34 server1 systemd[1]: rest-server.service: Scheduled restart job, restart counter is at 76.

Steps to reproduce the behavior

  1. Debian 12
  2. I ran rest-server for test scenarios successfully under normal user
    /usr/local/bin/rest-server --path /mnt/dummy --private-repos --append-only
  3. During implementing auto start https://github.com/restic/rest-server/blob/master/examples/systemd/rest-server.service my service didn't start with following message:

    Jul 19 20:23:29 server1 rest-server[26652]: error: unable to listen: listen on :8000 failed: listen tcp :8000: socket: address family not supported by protocol

Do you have any idea what may have caused this?

Yes

Do you have an idea how to solve the issue?

  1. comment out RestrictAddressFamilies=none in /etc/systemd/system/rest-server.service
  2. systemctl daemon reload
  3. systemctl start rest-server
danielfdickinson commented 1 month ago

The service file in the repo mentions that this is intended for use with a restic-server.socket and that if you don't use it that you need to uncomment PrivateNetwork=yes - this other option may need to be added as a comment in the service file repo, IMO there is no error.

fluidum commented 1 month ago

I am using /etc/systemd/system/rest-server.socket. I did also a test where commented out PrivateNetwork=yes instead my first finding. For me at least this looks more like a comment misunderstanding from example of restic-server.service than a error as well.