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

[Errno -2] Name or service not known #471

Closed
2ik opened this issue Aug 13, 2019 · 0 comments · Fixed by #472
Closed

[Errno -2] Name or service not known #471

2ik opened this issue Aug 13, 2019 · 0 comments · Fixed by #472

Comments

@2ik
Copy link

2ik commented Aug 13, 2019

  • asyncpg version: 0.18.3
  • PostgreSQL version: 11
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    :
  • Python version: 3.7
  • Platform: Linux Mint
  • Do you use pgbouncer?: No
  • Did you install asyncpg with pip?: Yes
  • If you built asyncpg locally, which version of Cython did you use?:
  • Can the issue be reproduced under both asyncio and
    uvloop?
    :

There was a similar question #467

I found a problem when connecting a pool with dsn transfer.

if the @ symbol is present in the password, then an error appears: [Errno -2] Name or service not known
if replaced by %40 then an access error password authentication failed for user "user_db"

Will give an example better:

# error:
dsn = 'postgresql://{user}:{pwd}@{host}:{port}/{database}'.format(
    host=config.DB_HOST,
    port=config.DB_PORT,
    user=config.DB_USER,
    pwd=config.DB_PASS, # passw@123
    database=config.DB_NAME
)

conn = await asyncpg.create_pool(dsn)

# successfully
conn = await asyncpg.create_pool(
    host=config.DB_HOST,
    port=config.DB_PORT,
    database=config.DB_NAME,
    user=config.DB_USER,
    password=config.DB_PASS # passw@123
)
elprans added a commit that referenced this issue Aug 19, 2019
When a connection string component contains characters that have a
special meaning in the URI (e.g. '@' or '='), percent-encoding must be
used.  asyncpg must take care to unquote the parsed components
correctly, and it doesn't currently.

Additionally, this makes asyncpg follow the libpq's behavior of parsing
the authentication part of netloc, i.e. split on the first '@' and not
the last.

Fixes: #418
Fixes: #471
@elprans elprans closed this as completed in 5513b9d Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant