NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.43k stars 13.64k forks source link

nextcloud28 notify_push Failed to connect to database #310335

Open 456634 opened 4 months ago

456634 commented 4 months ago

Describe the bug

I installed Nextcloud on a fresh NixOS installation. Nextcloud itself works flawlessly, but the notify_push service does not start.

journalctl -xeu nextcloud-notify_push.service

nextcloud-notify_push-start[762819]: Error:   × Failed to connect to database
nextcloud-notify_push-start[762819]:   ├─▶ error returned from database: 1698 (28000): Access denied for user
nextcloud-notify_push-start[762819]:   │   'nextcloud'@'localhost'
nextcloud-notify_push-start[762819]:   ╰─▶ 1698 (28000): Access denied for user 'nextcloud'@'localhost'
systemd[1]: nextcloud-notify_push.service: Main process exited, code=exited, status=1/FAILURE
...
...
nextcloud-notify_push-post-start[762818]: ✓ redis is configured
nextcloud-notify_push-post-start[762818]: 🗴 can't connect to push server: Server error: `GET https://cloud.****.com/push/test/cookie` resulted in a `502 Bad Gateway` response:
nextcloud-notify_push-post-start[762818]: <html>
nextcloud-notify_push-post-start[762818]: <head><title>502 Bad Gateway</title></head>
nextcloud-notify_push-post-start[762818]: <body>
nextcloud-notify_push-post-start[762818]: <center><h1>502 Bad Gateway</h1></center>
nextcloud-notify_push-post-start[762818]: <hr><center>ngin (truncated...)
May 09 14:38:29 stelzen-art systemd[1]: nextcloud-notify_push.service: Control process exited, code=exited, status=1/FAILURE
MariaDB [(none)]> SHOW GRANTS FOR 'nextcloud'@'localhost';
+--------------------------------------------------------------------------+
| Grants for nextcloud@localhost                                           |
+--------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `nextcloud`@`localhost` IDENTIFIED VIA unix_socket |
| GRANT ALL PRIVILEGES ON `nextcloud`.* TO `nextcloud`@`localhost`         |
+--------------------------------------------------------------------------+

Steps To Reproduce

Steps to reproduce the behavior: Config:

services.nextcloud = {
    enable = true;
    package = pkgs.nextcloud29;
    hostName = "cloud.*******.com";
    database.createLocally = true;
    config = {
      dbtype = "mysql";
      adminuser = "admin";
      adminpassFile = "/etc/nextcloud-admin-pass";
    };

    extraOptions = {
      allow_user_to_change_display_name = true;
      maintenance_window_start = 3;
    };

    https = true;

    caching = {
        apcu = true;
    }; 

    notify_push = {
        enable = true;
    };

    appstoreEnable = true;
    extraAppsEnable = true;
    extraApps = { inherit (pkgs.nextcloud28Packages.apps) "notify_push"; };
};

services.nginx.virtualHosts.${config.services.nextcloud.hostName} = {
    forceSSL = true;
    enableACME = true;
};
services.mysql = {
    enable = true;
    package = pkgs.mariadb;
    dataDir = "/var/lib/mysql";
};

Expected behavior

nextcloud-notify_push works

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.30, NixOS, 23.11 (Tapir), 23.11.6981.27c13997bf45`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos-23.11-small"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

@schneefux @bachp @globin @Ma27

Ma27 commented 2 months ago

Notify push sounds like something for @SuperSandro2000 to look at.

SuperSandro2000 commented 2 months ago

Access denied for user 'nextcloud'@'localhost'

Thats your problem, notify_push can't connect to your database. First of all I would try to use 127.0.0.1 instead of localhost as that could also resolve to ipv6. Also try using socket authentication.

I myself only ever tested the module with postgres and socket authentication.