[GH-ISSUE #1276] "unable to open database: No such file or directory" #902

Closed
opened 2026-05-07 00:28:35 +02:00 by BreizhHardware · 11 comments

Originally created by @matthiasbeyer on GitHub (Feb 9, 2025).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1276

🐞 Describe the bug

I have issues setting up the software because it does not tell me what file or directory does not exist. All files that are configured via the configuration file do exist.

Would be very nice if the log output would tell what paths are affected, which would simplify debugging a log.

💻 Components impacted

ntfy server

💡 Screenshots and/or logs

Feb 09 11:33:12 home systemd[1]: Started Push notifications server.
Feb 09 11:33:12 home ntfy[206929]: 2025/02/09 11:33:12 FATAL unable to open database file: no such file or directory (exit_code=1)
Feb 09 11:33:12 home ntfy[206929]: unable to open database file: no such file or directory

🔮 Additional context

Originally created by @matthiasbeyer on GitHub (Feb 9, 2025). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1276 :lady_beetle: **Describe the bug** I have issues setting up the software because it does not tell me what file or directory does not exist. All files that are configured via the configuration file do exist. Would be very nice if the log output would tell what paths are affected, which would simplify debugging a log. :computer: **Components impacted** ntfy server :bulb: **Screenshots and/or logs** ``` Feb 09 11:33:12 home systemd[1]: Started Push notifications server. Feb 09 11:33:12 home ntfy[206929]: 2025/02/09 11:33:12 FATAL unable to open database file: no such file or directory (exit_code=1) Feb 09 11:33:12 home ntfy[206929]: unable to open database file: no such file or directory ``` :crystal_ball: **Additional context** <!-- Add any other context about the problem here. -->
BreizhHardware 2026-05-07 00:28:35 +02:00
  • closed this issue
  • added the
    🪲 bug
    label
Author
Owner

@matthiasbeyer commented on GitHub (Feb 9, 2025):

After touching files as root and chmod a+rwing them, ntfy fails with

217508 unlink("/var/cache/ntfy/cache.db-journal") = -1 EACCES (Permission denied)

(strace output).

The path in question is

-rw-rw-rw- 1 root root   512  9. Feb 12:22 cache.db-journal

So I don't know why this fails.

<!-- gh-comment-id:2646185598 --> @matthiasbeyer commented on GitHub (Feb 9, 2025): After `touch`ing files as `root` and `chmod a+rw`ing them, `ntfy` fails with ``` 217508 unlink("/var/cache/ntfy/cache.db-journal") = -1 EACCES (Permission denied) ``` (strace output). The path in question is ``` -rw-rw-rw- 1 root root 512 9. Feb 12:22 cache.db-journal ``` So I don't know why this fails.
Author
Owner

@wunter8 commented on GitHub (Feb 9, 2025):

I agree that printing the path of the failed directory/file would be very helpful.

In general, you shouldn't need to create any files manually (e.g., via touch). As long as ntfy can read/write in the directories you configured, it will create the files it needs.

It looks like you're using systemd. Is it the default service file that comes with the ntfy package? If so, the ntfy server will run under the ntfy user instead of root. That doesn't make a difference for this particular file since it has a+rw, but if all of the directories leading to this folder do not have o+x, ntfy will not be able to read files in the folder.

To test things, you can incrementally ls as the ntfy user:

  • sudo -u ntfy ls /var
  • sudo -u ntfy ls /var/cache
  • sudo -u ntfy ls /var/cache/ntfy
  • sudo -u ntfy ls /var/cache/ntfy/cache.db-journal

One (or more) will likely fail because the directory does not have o+x permissions

<!-- gh-comment-id:2646322680 --> @wunter8 commented on GitHub (Feb 9, 2025): I agree that printing the path of the failed directory/file would be very helpful. In general, you shouldn't need to create any files manually (e.g., via `touch`). As long as ntfy can read/write in the directories you configured, it will create the files it needs. It looks like you're using systemd. Is it the default service file that comes with the ntfy package? If so, the ntfy server will run under the `ntfy` user instead of `root`. That doesn't make a difference for this particular file since it has `a+rw`, but if all of the directories leading to this folder do not have `o+x`, ntfy will not be able to read files in the folder. To test things, you can incrementally `ls` as the ntfy user: - `sudo -u ntfy ls /var` - `sudo -u ntfy ls /var/cache` - `sudo -u ntfy ls /var/cache/ntfy` - `sudo -u ntfy ls /var/cache/ntfy/cache.db-journal` One (or more) will likely fail because the directory does not have `o+x` permissions
Author
Owner

@matthiasbeyer commented on GitHub (Feb 9, 2025):

It looks like you're using systemd. Is it the default service file that comes with the ntfy package?

Yes, its systemd. No, the service is generated via the nixos module system.

If so, the ntfy server will run under the ntfy user instead of root

It runs under ntfy-sh user and group.


That said, I got it running. The issue was apparently that the nixos module configures the user/group not properly... either way the issue was definitively not on ntfys side, but on nixos side.

That being said, (and to help others that might stumble over this issue,) configuring the server with sudo -u ntfy-sh ntfy user add (or ntfy-sh as user) does not work, probably because some systemd shenanigans that nixos introduces.
Using root works tho and I successfully added my user and tokens.


All the above does not change the fact that the logging output of ntfy was not helpful for debugging the issue at hand, and I would like to keep this open (or rather let you decide what is the proper way for the project workflow of course) until that is resolved.

Thanks for your patience! ❤

<!-- gh-comment-id:2646398933 --> @matthiasbeyer commented on GitHub (Feb 9, 2025): > It looks like you're using systemd. Is it the default service file that comes with the ntfy package? Yes, its systemd. No, the service is generated via the nixos module system. > If so, the ntfy server will run under the ntfy user instead of root It runs under `ntfy-sh` user and group. --- That said, I got it running. The issue was apparently that the nixos module configures the user/group not properly... either way the issue was definitively not on `ntfy`s side, but on nixos side. That being said, (and to help others that might stumble over this issue,) configuring the server with `sudo -u ntfy-sh ntfy user add` (or `ntfy-sh` as user) does not work, probably because some systemd shenanigans that nixos introduces. Using root works tho and I successfully added my user and tokens. --- All the above does not change the fact that the logging output of `ntfy` was not helpful for debugging the issue at hand, and I would like to keep this open (or rather let you decide what is the proper way for the project workflow of course) until that is resolved. Thanks for your patience! ❤
Author
Owner

@DestinyofYeet commented on GitHub (Feb 10, 2025):

For any other nixos user coming across this, here is some info:

The nixos module sets a few systemd options for example ProtectSystem=full and StateDirectory=ntfy-sh, so it doesn't allow access to anything other than /var/lib/ntfy-sh. Setting my cache-file and attachement-cache-dirto start with /var/lib/ntfy-sh fixed the issue for me.

<!-- gh-comment-id:2648564829 --> @DestinyofYeet commented on GitHub (Feb 10, 2025): For any other nixos user coming across this, here is some info: The nixos module sets a few systemd options for example `ProtectSystem=full` and `StateDirectory=ntfy-sh`, so it doesn't allow access to anything other than `/var/lib/ntfy-sh`. Setting my `cache-file` and `attachement-cache-dir`to start with `/var/lib/ntfy-sh` fixed the issue for me.
Author
Owner

@crushndent commented on GitHub (Mar 1, 2025):

Same problem in a Docker container. Anytime ENV vars are set for AUTH_FILE or CACHE_FILE or CACHE_DIR. Not clear how to fix this. I persisted the volume and can't get it to stick when I set the AUTH_FILE. Not clear what is happening.
Too bad we can't just pass an ENV: TOKEN without making all this other stuff.

<!-- gh-comment-id:2692363676 --> @crushndent commented on GitHub (Mar 1, 2025): Same problem in a Docker container. Anytime ENV vars are set for AUTH_FILE or CACHE_FILE or CACHE_DIR. Not clear how to fix this. I persisted the volume and can't get it to stick when I set the AUTH_FILE. Not clear what is happening. Too bad we can't just pass an ENV: TOKEN without making all this other stuff.
Author
Owner

@hockeygoalie35 commented on GitHub (May 2, 2025):

Same issue here, when trying to enable NTFY_CACHE_FILE in a docker .env file.

<!-- gh-comment-id:2846255974 --> @hockeygoalie35 commented on GitHub (May 2, 2025): Same issue here, when trying to enable `NTFY_CACHE_FILE` in a docker .env file.
Author
Owner

@philipwilk commented on GitHub (May 19, 2025):

For any other nixos user coming across this, here is some info:

The nixos module sets a few systemd options for example ProtectSystem=full and StateDirectory=ntfy-sh, so it doesn't allow access to anything other than /var/lib/ntfy-sh. Setting my cache-file and attachement-cache-dirto start with /var/lib/ntfy-sh fixed the issue for me.

Alternatively, a more ideal solution, is to use systemd.services.ntfy-sh.serviceConfig.ReadWritePaths, such that

systemd.services.ntfy-sh.serviceConfig.ReadWritePaths = [
  stateDir
  cacheDir
  # et al ...
];

Similarly, for firebase-key-file you are likely to want to use LoadCredential, such that

systemd.services.ntfy-sh.serviceConfig.LoadCredential = [
  "firebase.json:${config.age.secrets.(yourSecretNameHere).path}"
];
services.ntfy-sh.settings.firebase-key-file = "/run/credentials/ntfy-sh.service/firebase.json";
<!-- gh-comment-id:2890505473 --> @philipwilk commented on GitHub (May 19, 2025): > For any other nixos user coming across this, here is some info: > > The nixos module sets a few systemd options for example `ProtectSystem=full` and `StateDirectory=ntfy-sh`, so it doesn't allow access to anything other than `/var/lib/ntfy-sh`. Setting my `cache-file` and `attachement-cache-dir`to start with `/var/lib/ntfy-sh` fixed the issue for me. Alternatively, a more ideal solution, is to use `systemd.services.ntfy-sh.serviceConfig.ReadWritePaths`, such that ```nix systemd.services.ntfy-sh.serviceConfig.ReadWritePaths = [ stateDir cacheDir # et al ... ]; ``` Similarly, for firebase-key-file you are likely to want to use `LoadCredential`, such that ```nix systemd.services.ntfy-sh.serviceConfig.LoadCredential = [ "firebase.json:${config.age.secrets.(yourSecretNameHere).path}" ]; services.ntfy-sh.settings.firebase-key-file = "/run/credentials/ntfy-sh.service/firebase.json"; ```
Author
Owner

@Math-Aumont commented on GitHub (Aug 6, 2025):

Just set up ntfy build from the source and same problem on FreeBSD with root ...
I can't create any user and I didn't find any workarround

for now I can't create or list users ....

/usr/local/sbin/ntfy serve --config /usr/local/etc/ntfy.yml --log-file /var/log/ntfy.log --debug

root@ntfy:~ # ntfy user list
option auth-file not set; auth is unconfigured for this server

Config file : /usr/local/etc/ntfy.yml

base-url: http://ntfy.domain.com
listen-http: ":4444"
auth-file: "/var/db/ntfy/user.db"
cache-file: "/var/db/ntfy/cache.db"
behind-proxy: true

Trace mode

read(6,"\r\0\0\0\0\^P\0\0\0\0\0\0\0\0\0"...,4096) = 4096 (0x1000)
fstatat(AT_FDCWD,"/var",{ mode=drwxr-xr-x ,inode=23,size=24,blksize=4096 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
fstatat(AT_FDCWD,"/var/db",{ mode=drwxr-xr-x ,inode=51,size=19,blksize=4096 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
fstatat(AT_FDCWD,"/var/db/ntfy",{ mode=drwxr-xr-x ,inode=69008,size=4,blksize=131072 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
fstatat(AT_FDCWD,"/var/db/ntfy/user.db",{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
getpid()                                         = 80759 (0x13b77)
fstatat(AT_FDCWD,"/var/db/ntfy/user.db",{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 },0x0) = 0 (0x0)
openat(AT_FDCWD,"/var/db/ntfy/user.db",O_RDWR|O_NOFOLLOW|O_CREAT|O_CLOEXEC,0644) = 7 (0x7)
fstat(7,{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 }) = 0 (0x0)
fstat(7,{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 }) = 0 (0x0)
fstatat(AT_FDCWD,"/var/db/ntfy/user.db",{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 },0x0) = 0 (0x0)
lseek(7,0x0,SEEK_SET)                            = 0 (0x0)
read(7,"SQLite format 3\0\^P\0\^A\^A\0@ "...,100) = 100 (0x64)
fstatat(AT_FDCWD,"/var/db/ntfy/user.db-journal",0x876326cf8,0x0) ERR#2 'No such file or directory'
fstatat(AT_FDCWD,"/var/db/ntfy/user.db-wal",0x876326cc8,0x0) ERR#2 'No such file or directory'
fstat(7,{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 }) = 0 (0x0)
lseek(7,0x0,SEEK_SET)                            = 0 (0x0)
read(7,"SQLite format 3\0\^P\0\^A\^A\0@ "...,4096) = 4096 (0x1000)
fstatat(AT_FDCWD,"/var/db/ntfy/user.db-journal",0x876327a28,0x0) ERR#2 'No such file or directory'
lseek(7,0x18,SEEK_SET)                           = 24 (0x18)
read(7,"\0\0\0\^C\0\0\0\^T\0\0\0\0\0\0\0"...,16) = 16 (0x10)
fstatat(AT_FDCWD,"/var/db/ntfy/user.db-wal",0x8763279f8,0x0) ERR#2 'No such file or directory'
fstat(7,{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 }) = 0 (0x0)

this is weird The trace clearly shows that it is able to read the file "/var/db/ntfy/user.db

<!-- gh-comment-id:3161810113 --> @Math-Aumont commented on GitHub (Aug 6, 2025): Just set up ntfy build from the source and same problem on FreeBSD with root ... I can't create any user and I didn't find any workarround for now I can't create or list users .... `/usr/local/sbin/ntfy serve --config /usr/local/etc/ntfy.yml --log-file /var/log/ntfy.log --debug` ``` root@ntfy:~ # ntfy user list option auth-file not set; auth is unconfigured for this server ``` Config file : `/usr/local/etc/ntfy.yml` ``` base-url: http://ntfy.domain.com listen-http: ":4444" auth-file: "/var/db/ntfy/user.db" cache-file: "/var/db/ntfy/cache.db" behind-proxy: true ``` Trace mode ``` read(6,"\r\0\0\0\0\^P\0\0\0\0\0\0\0\0\0"...,4096) = 4096 (0x1000) fstatat(AT_FDCWD,"/var",{ mode=drwxr-xr-x ,inode=23,size=24,blksize=4096 },AT_SYMLINK_NOFOLLOW) = 0 (0x0) fstatat(AT_FDCWD,"/var/db",{ mode=drwxr-xr-x ,inode=51,size=19,blksize=4096 },AT_SYMLINK_NOFOLLOW) = 0 (0x0) fstatat(AT_FDCWD,"/var/db/ntfy",{ mode=drwxr-xr-x ,inode=69008,size=4,blksize=131072 },AT_SYMLINK_NOFOLLOW) = 0 (0x0) fstatat(AT_FDCWD,"/var/db/ntfy/user.db",{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 },AT_SYMLINK_NOFOLLOW) = 0 (0x0) getpid() = 80759 (0x13b77) fstatat(AT_FDCWD,"/var/db/ntfy/user.db",{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 },0x0) = 0 (0x0) openat(AT_FDCWD,"/var/db/ntfy/user.db",O_RDWR|O_NOFOLLOW|O_CREAT|O_CLOEXEC,0644) = 7 (0x7) fstat(7,{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 }) = 0 (0x0) fstat(7,{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 }) = 0 (0x0) fstatat(AT_FDCWD,"/var/db/ntfy/user.db",{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 },0x0) = 0 (0x0) lseek(7,0x0,SEEK_SET) = 0 (0x0) read(7,"SQLite format 3\0\^P\0\^A\^A\0@ "...,100) = 100 (0x64) fstatat(AT_FDCWD,"/var/db/ntfy/user.db-journal",0x876326cf8,0x0) ERR#2 'No such file or directory' fstatat(AT_FDCWD,"/var/db/ntfy/user.db-wal",0x876326cc8,0x0) ERR#2 'No such file or directory' fstat(7,{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 }) = 0 (0x0) lseek(7,0x0,SEEK_SET) = 0 (0x0) read(7,"SQLite format 3\0\^P\0\^A\^A\0@ "...,4096) = 4096 (0x1000) fstatat(AT_FDCWD,"/var/db/ntfy/user.db-journal",0x876327a28,0x0) ERR#2 'No such file or directory' lseek(7,0x18,SEEK_SET) = 24 (0x18) read(7,"\0\0\0\^C\0\0\0\^T\0\0\0\0\0\0\0"...,16) = 16 (0x10) fstatat(AT_FDCWD,"/var/db/ntfy/user.db-wal",0x8763279f8,0x0) ERR#2 'No such file or directory' fstat(7,{ mode=-rw-r--r-- ,inode=69015,size=81920,blksize=81920 }) = 0 (0x0) ``` this is weird The trace clearly shows that it is able to read the file `"/var/db/ntfy/user.db`
Author
Owner

@wunter8 commented on GitHub (Aug 6, 2025):

@Math-Aumont when you run any ntfy command as root (e.g., ntfy serve ..., ntfy user ..., etc.), it will look for a config file in /etc/ntfy/server.yml. Since your config file is at /usr/local/etc/ntfy/ntfy.yml, the ntfy user command is not finding it and using it. (I'm not sure why the trace is showing it accessing the DB file, unless that's a trace of the ntfy serve command, where you're providing a path to the config file)

The solution is to provide a path to the config file for the ntfy user command like you did for the ntfy serve command: ntfy user --config /usr/local/etc/ntfy/ntfy.yml list

<!-- gh-comment-id:3161847892 --> @wunter8 commented on GitHub (Aug 6, 2025): @Math-Aumont when you run any `ntfy` command as root (e.g., `ntfy serve ...`, `ntfy user ...`, etc.), it will look for a config file in `/etc/ntfy/server.yml`. Since your config file is at `/usr/local/etc/ntfy/ntfy.yml`, the `ntfy user` command is not finding it and using it. (I'm not sure why the trace is showing it accessing the DB file, unless that's a trace of the `ntfy serve` command, where you're providing a path to the config file) The solution is to provide a path to the config file for the `ntfy user` command like you did for the `ntfy serve` command: `ntfy user --config /usr/local/etc/ntfy/ntfy.yml list`
Author
Owner

@Math-Aumont commented on GitHub (Aug 6, 2025):

Holy cow, thank you so much 🥇

I searched for hours without understanding what was wrong... I didn't realize for a moment that I had to provide the yaml configuration file when running the “user” command as well 🫢

BTW the trace was from the server side.

<!-- gh-comment-id:3161855396 --> @Math-Aumont commented on GitHub (Aug 6, 2025): Holy cow, thank you so much 🥇 I searched for hours without understanding what was wrong... I didn't realize for a moment that I had to provide the yaml configuration file when running the “user” command as well 🫢 BTW the trace was from the server side.
Author
Owner

@matous-volf commented on GitHub (Sep 7, 2025):

For @DestinyofYeet, @crushndent or anyone encountering this issue with Docker: The following configuration works for me.

server.yml:

auth-file: "/var/lib/ntfy/user.db"
cache-file: "/var/cache/ntfy/messages.sqlite"

Dockerfile:

FROM binwiederhier/ntfy:v2.14.0@sha256:5a051798d14138c3ecb12c038652558ab6a077e1aceeb867c151cbf5fa8451ef

RUN mkdir -p /var/cache/ntfy/attachments /var/lib/ntfy \
 && chown -R 1000:1000 /var/cache/ntfy /var/lib/ntfy \
 && chmod -R u=rwx /var/cache/ntfy /var/lib/ntfy

USER 1000:1000

COPY server.yaml /etc/ntfy/server.yml
<!-- gh-comment-id:3263960639 --> @matous-volf commented on GitHub (Sep 7, 2025): For @DestinyofYeet, @crushndent or anyone encountering this issue with Docker: The following configuration works for me. server.yml: ```yaml auth-file: "/var/lib/ntfy/user.db" cache-file: "/var/cache/ntfy/messages.sqlite" ``` Dockerfile: ```Dockerfile FROM binwiederhier/ntfy:v2.14.0@sha256:5a051798d14138c3ecb12c038652558ab6a077e1aceeb867c151cbf5fa8451ef RUN mkdir -p /var/cache/ntfy/attachments /var/lib/ntfy \ && chown -R 1000:1000 /var/cache/ntfy /var/lib/ntfy \ && chmod -R u=rwx /var/cache/ntfy /var/lib/ntfy USER 1000:1000 COPY server.yaml /etc/ntfy/server.yml ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#902
No description provided.