Skip to content

Please help: Error using password in connect string  #1285

Closed
@JamesInform

Description

@JamesInform

Hi,

I want to connect to my PostgreSQL server:
Host: 127.0.0.1
Port: 5432
User: postgres
Password: mypass12#
Database: postgres

When I use the following connect:
conn, err := pgx.Connect(context.Background(), "postgres://postgres:mypass12#@127.0.0.1:5432/postgres")

I get this error
Unable to connect to database: cannot parse postgres://postgres:[email protected]:5432/postgres: failed to parse as URL (parse "postgres://postgres:mypass12": invalid port ":mypass12" after host)

The error seems to appear when using "#" as a character for the password.

The same connect string works just fine when using it with psql:
psql postgres://postgres:mypass12#@127.0.0.1:5432/postgres

Metadata

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