listmonk icon indicating copy to clipboard operation
listmonk copied to clipboard

postgres socket connection uses the wrong value for database

Open mapreri opened this issue 11 months ago • 12 comments

Version:

  • listmonk: v4.1.0
  • OS: Debian 12 (bookworm)

Description of the bug and steps to reproduce:

Trying to install listmonk using unix socket auth

[db]
#host = "localhost"
host = "/var/run/postgresql/"
port = 5433
user = "myuser"
#password = "listmonk"

# Ensure that this database has been created in Postgres.
database = "listmonk"

This shows this on --install:

2025/01/30 07:32:02.942176 main.go:107: v4.1.0 (0a27de1 2024-11-12T18:42:26Z, linux/amd64)
2025/01/30 07:32:02.942285 init.go:163: reading config: config.toml
2025/01/30 07:32:02.942525 init.go:303: connecting to db: /var/run/postgresql/:5433/listmonk
2025/01/30 07:32:02.943965 init.go:307: error connecting to DB: pq: database "myuser" does not exist

It should be noted that:

  • the user "myuser" exists
  • the database "listmonk" exists

I then created a database named "myuser", and --install proceeded:

2025/01/30 07:32:52.730536 main.go:107: v4.1.0 (0a27de1 2024-11-12T18:42:26Z, linux/amd64)
2025/01/30 07:32:52.730905 init.go:163: reading config: config.toml
2025/01/30 07:32:52.731260 init.go:303: connecting to db: /var/run/postgresql/:5433/listmonk

** first time installation **
** IMPORTANT: This will wipe existing listmonk tables and types in the DB 'listmonk' **
continue (y/N)?  y
2025/01/30 07:32:57.871222 install.go:88: no Super Admin user created. Visit webpage to create user.
2025/01/30 07:32:57.871257 install.go:91: setup complete
2025/01/30 07:32:57.871263 install.go:92: run the program and access the dashboard at localhost:9000

The log keeps talking about the "listmonk" database, but I verifying that the installation was done on the "myuser" database.

mapreri avatar Jan 30 '25 07:01 mapreri

hm, I'm not sure how this is happening. The connection string is a standard Postgres DSN string made out of variables in the config:

https://github.com/knadh/listmonk/blob/ad162c259acd3dad9873a3ea25d9e2f2ed645239/cmd/init.go#L306

https://github.com/knadh/listmonk/blob/ad162c259acd3dad9873a3ea25d9e2f2ed645239/cmd/install.go#L24

If you don't have database = "listmonk" in the config (or the env variable for it configured), then the log won't print "listmonk" as the database name. It comes from the config.

knadh avatar Feb 05 '25 17:02 knadh

Why completed?

I don't see how this was fixed?

On Tue, 11 Feb 2025, 7:54 pm Kailash Nadh, @.***> wrote:

Closed #2275 https://github.com/knadh/listmonk/issues/2275 as completed.

— Reply to this email directly, view it on GitHub https://github.com/knadh/listmonk/issues/2275#event-16269699682, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL7FE2CTTPO3GKGNA3WLKL2PJBMTAVCNFSM6AAAAABWETBDBKVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJWGI3DSNRZHE3DQMQ . You are receiving this because you authored the thread. Message ID: @.***>

mapreri avatar Feb 12 '25 00:02 mapreri

Ah, I assumed this was a misconfiguration and was resolved after seeing no response. Please see my previous comment.

knadh avatar Feb 12 '25 05:02 knadh

Right, I can confirm you that I have a database="listmonk" in my config (see the excerpt in the first post). I'm really as baffled as you here, especially given the disconnect between the log, and what then actually happens.

2025/01/30 07:32:02.942525 init.go:303: connecting to db: /var/run/postgresql/:5433/listmonk
2025/01/30 07:32:02.943965 init.go:307: error connecting to DB: pq: database "myuser" does not exist

just look at these two lines, where just 0.0015 seconds after the databse name apparently changes...

Please tell me if and how I could help in debugging.

mapreri avatar Feb 13 '25 06:02 mapreri

@knadh do you have idea where this issue might be coming from?

(commenting since this issue is closed, I wouldn't want it to be lost)

mapreri avatar Feb 24 '25 20:02 mapreri

I've been unable to reproduce this, unfortunately. Will leave this open for anyone with time to debug.

knadh avatar Feb 26 '25 05:02 knadh

This issue has been marked 'stale' after 90 days of inactivity. If there is no further activity, it will be closed in 7 days.

github-actions[bot] avatar May 28 '25 02:05 github-actions[bot]

well, I can confirm this did not change between 1.4.2 and 1.5.1, so it's still there.

mapreri avatar May 28 '25 09:05 mapreri

This issue has been marked 'stale' after 90 days of inactivity. If there is no further activity, it will be closed in 7 days.

github-actions[bot] avatar Aug 28 '25 02:08 github-actions[bot]

Nope.

regards, Mattia Rizzolo

GPG Key: 4096R/B9444540 http://goo.gl/I8TMB more about me: http://mapreri.org Launchpad User: https://launchpad.net/~mapreri Ubuntu Wiki page: https://wiki.ubuntu.com/MattiaRizzolo

On Thu, 28 Aug 2025, 5:05 am github-actions[bot], @.***> wrote:

github-actions[bot] left a comment (knadh/listmonk#2275) https://github.com/knadh/listmonk/issues/2275#issuecomment-3231184286

This issue has been marked 'stale' after 90 days of inactivity. If there is no further activity, it will be closed in 7 days.

— Reply to this email directly, view it on GitHub https://github.com/knadh/listmonk/issues/2275#issuecomment-3231184286, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL7FEYY56IDIIELWC5JVR33PZPWZAVCNFSM6AAAAABWETBDBKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMZRGE4DIMRYGY . You are receiving this because you authored the thread.Message ID: @.***>

mapreri avatar Aug 28 '25 05:08 mapreri