Skip to content

PGWEB_DATABASE_URL error if it includes symbols with special meaning in any of its parts of password #754

Open
@julianojstavares

Description

Hi Dan, how are you? I'm using PGWEB in a personal project and I spent some time configuring a docker compose to use a postgresql image along with a pgweb image

docker-compose.txt

I started to notice a problem by chance, when trying to run multiple containers, both from pgweb and postgresql, through different composes, in different projects. In one project, the Connection URI passed in the PGWEB_DATABASE_URL variable made pgweb connect automatically, and in another project it did not. When it did not connect automatically, the error below was displayed on the console

Connecting to server...
dbtestclient-container  | Error: dial tcp: lookup W on 127.0.0.11:53: no such host
dbtestclient-container  | Pgweb v0.16.1 (git: 136b2a6942fca534b59f870c507cae2806895bef) (go: go1.22.7) (build time: 2024-09-07T16:49:17Z) (arch: linux/amd64)

This made me spend hours trying to investigate host issues, thinking that some host configuration was wrong due to the use of docker. I tried everything. Then I started to suspect that the Docker Compose settings were all correct, because in another project everything was working, and in the other it wasn't.

When I compared what was different, I noticed that the only difference was the database password used in each project. So what I did was basically test the password (1q2w3e!Q@W#E) that returns the error mentioned above, and then I tested a password without special characters (psw) and it worked!

Conclusion: There was nothing related to a host error, as the error log suggested. If you can't solve the problem, but at least change the log string, that would be pretty cool hahaha

I went to take a look here
https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
and it seems like
"The connection URI needs to be encoded with percent-encoding if it includes symbols with special meaning in any of its parts."

So here's a tip to treat the variables received in the connection uri, or else, make it possible to pass them one by one, as I imagine it's easier to treat each variable individually, than passing everything at once as is currently done here

PGWEB_DATABASE_URL: postgres://pgweb:pgweb@pgweb-postgres:5432/pgweb?sslmode=disable
.

Disclaimer: Forgive me if I didn't open the issue correctly. I don't really know how to do that. But, I felt obliged to try to help you and let you know about the error, as I'm using pgweb and I really like it 😄

Oh, and I'm using Google Translate here because I'm Brazilian, I only speak Portuguese as a language, so I hope the translation into English is good enough. Greetings from Brazil!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions