I’m trying to setup Vikunja to use PostgreSQL with peer authentication, and it should just work, but it’s not for some reason. It’s failing with this error:
migration/Migrate 004 Migration failed: pq: Peer authentication failed for user "vikunja"
This is my configuration:
service:
interface: ":3456"
frontendurl: "https://tasks.example.com/"
database:
type: "postgres"
host: "/run/postgresql"
files:
basepath: "/var/lib/vikunja/files"
I’ve made sure to create both a PostgreSQL user database named vikunja
, and I made sure the user owned the database. The Vikunja systemd service is running as Linux user vikunja
, so peer authentication should just work.
Did you allow connections over socket? Does it work if you try to connect vikunja via hostname?
Did you allow connections over socket?
Yeah. It works with every other service I’ve setup to use peer authentication (e.g. Nextcloud, Authelia, etc.)
Does it work if you try to connect vikunja via hostname?
No, and it gives this, which is expected, as the user doesn’t have a password. I’m trying to get peer authentication setup so I don’t have to.
migration/Migrate 004 Migration failed: pq: password authentication failed for user "vikunja"
Is there any PostgreSQL command I can use to verify things?
I don’t know a lot about how postgres handles these things so I’ve asked Claude (Think ChatGPT) about how to troubleshoot this:
(though I guess you probably already did most of that?)
-
Verify PostgreSQL configuration:
Check your pg_hba.conf file (usually located in /etc/postgresql/{version}/main/) to ensure peer authentication is properly configured for local connections. You should see a line like:
local all vikunja peer
-
Check user permissions:
Ensure that the Linux user ‘vikunja’ has the necessary permissions to access the PostgreSQL socket. You can try:
sudo -u vikunja psql -d vikunja
If this works, it confirms that peer authentication is functioning correctly for the ‘vikunja’ user.
-
Verify database ownership:
Double-check that the ‘vikunja’ database is indeed owned by the ‘vikunja’ PostgreSQL user:
\l
in psql to list databases and their owners.
-
Check Vikunja service:
Ensure that the Vikunja service is actually running as the ‘vikunja’ user. You can verify this with:
ps aux | grep vikunja
-
Logs:
Check both Vikunja and PostgreSQL logs for any additional error messages that might provide more context.
-
SELinux:
If you’re running SELinux, make sure it’s not interfering with the connection. You can temporarily disable it to test:
sudo setenforce 0
1 Like
Thank you, looks like I had to just add this to my configuration file:
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust