Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgres socket connection uses the wrong value for database #2275

Open
mapreri opened this issue Jan 30, 2025 · 1 comment
Open

postgres socket connection uses the wrong value for database #2275

mapreri opened this issue Jan 30, 2025 · 1 comment
Labels
needs-investigation Potential bug. Needs investigation

Comments

@mapreri
Copy link

mapreri commented Jan 30, 2025

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 mapreri added the bug Something isn't working label Jan 30, 2025
@knadh
Copy link
Owner

knadh commented Feb 5, 2025

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:

fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s %s", c.Host, c.Port, c.User, c.Password, c.DBName, c.SSLMode, c.Params))

ko.String("db.database"))

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 knadh added needs-investigation Potential bug. Needs investigation and removed bug Something isn't working labels Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-investigation Potential bug. Needs investigation
Projects
None yet
Development

No branches or pull requests

2 participants