Restic init 401 Unauthorized

Hey! I’m trying to set up restic to back up my Windwows laptop onto my QNAP NAS, so I’ve been following this tutorial: Backup all the things with restic - Braincoke | Security Blog

The docker container is running on the NAS, the problem happens when I run restic init. Here’s the full command: restic -r rest:http://192.168.1.233:8000/share/Laptop/ init --insecure-no-password

This is the output: Fatal: create repository at rest:http://192.168.1.233:8000/share/Laptop/ failed: Fatal: unable to open repository at rest:http://192.168.1.233:8000/share/Laptop/: unexpected HTTP response (401): 401 Unauthorized

It appears that restic itself is rejecting the request, for some reason. Any ideas on what might be wrong with my setup? Thanks in advance!

1 Like

Have you configured credentials (via .htpasswd file)? If not needed you have to explicitly disable authentication. All details in docs:

2 Likes

I just checked, /data/.htpasswd is there. I also set DISABLE_AUTHENTICATION, so now it shouldn’t matter anyway, right?

The problem persists, sadly. But I saw a command on the readme that wasn’t in that tutorial I was following: rest-server --path /user/home/backup --no-auth do I need to run this before restic init to actually run the rest server? I tried running that on the docker and got this:

Authentication disabled
Private repositories disabled
error: unable to listen: listen on :8000 failed: listen tcp :8000: bind: address already in use```

Thanks for your help so far, by the way!

This means that another instanse of probably rest-server is running. Make sure you stop it.

1 Like

Thank you so much, I was able to solve the problem! I hadn’t realized that there were 3 passwords involved, docker container, rest-server and restic repository. I couldn’t stop the rest-server because it was the container’s PID 1 process, but I modified the docker run command to disable rest-server authentication:
docker run -p 8000:8000 -v /share/Laptop --name rest_server --env DISABLE_AUTHENTICATION=1 -i -t restic/rest-server

I initialized my first restic repository successfully. Hopefully everything will go smoothly from here. Thanks again for taking the time to help me!

1 Like