Pgadmin4 won't start

I’m running pgadmin4 on NixOS unstable.

Setting up a new system and pgadmin4 doesn’t want to start.

I’m using this config structure:

    pgadmin = {
      enable = true;
      initialEmail = "<email here>";
      initialPasswordFile = "<filename here>";
    };

Here’s what I’m seeing in the logs:

× pgadmin.service
     Loaded: loaded (/etc/systemd/system/pgadmin.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2022-12-06 18:11:27 EST; 114ms ago
    Process: 344198 ExecStartPre=/nix/store/2f0ab1sdqf46l8hvkr4igqjgr0bfh8aq-unit-script-pgadmin-pre-start/bin/pgadmin-pre-start (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 754ms

Dec 06 18:11:27 dab-xps9520-nixos pgadmin-pre-start[344213]:   File "/nix/store/li8abkaw8kh1i7y03m2iwplm8qp2d0l9-pgadmin-6.17/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py", line 409, in run_migration_for_sqlite
Dec 06 18:11:27 dab-xps9520-nixos pgadmin-pre-start[344213]:     upgrade_db()
Dec 06 18:11:27 dab-xps9520-nixos pgadmin-pre-start[344213]:   File "/nix/store/li8abkaw8kh1i7y03m2iwplm8qp2d0l9-pgadmin-6.17/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py", line 390, in upgrade_db
Dec 06 18:11:27 dab-xps9520-nixos pgadmin-pre-start[344213]:     backup_db_file()
Dec 06 18:11:27 dab-xps9520-nixos pgadmin-pre-start[344213]:   File "/nix/store/li8abkaw8kh1i7y03m2iwplm8qp2d0l9-pgadmin-6.17/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py", line 380, in backup_db_file
Dec 06 18:11:27 dab-xps9520-nixos pgadmin-pre-start[344213]:     raise RuntimeError('Migration failed')
Dec 06 18:11:27 dab-xps9520-nixos pgadmin-pre-start[344213]: RuntimeError: Migration failed
Dec 06 18:11:27 dab-xps9520-nixos systemd[1]: pgadmin.service: Control process exited, code=exited, status=1/FAILURE
Dec 06 18:11:27 dab-xps9520-nixos systemd[1]: pgadmin.service: Failed with result 'exit-code'.
Dec 06 18:11:27 dab-xps9520-nixos systemd[1]: Failed to start pgadmin.service.

@gador

1 Like

Interesting. I’m off to work now and can have a look at it later today

1 Like

I got the same error earlier today before I realized the initialPasswordFile has improper permission (owner/group) configured.

But the truncated error log cannot tell whether it is the same issue. Usually the full log can be checked with journalctl -eu pgadmin.

1 Like

@Lot I bet that’s it. Remind me what’s the proper permission (owner/group) or how to determine that?

I find
config.users.users.pgadmin.{name,group} works.

With sops-nix, my config is:

Yes, this might be a permissions error. Like @Lot mentioned, the whole log could be useful.

For reference, I have 400 permissions on the file and owner/group are pgadmin/root.
(The user stems from here)