1

I've got a problem during connecting database from command line tool - SQL Shell. I cant connect database using command \c test localhost postgres 5432

After using it I receive message:

could not translate host name "postgres" to address: Unknown host Previous connection kept

Although I can connect using pgAdmin 4. Does anyone know how to fix this? I'm working on Windows 10, I have the newest version of PostgreSQL.

1
  • Look up the order of the arguments for \c Commented Jan 3, 2022 at 10:56

1 Answer 1

1

According to postgres document if you want CLI for to connect database you have to use like that:

=> \c mydb myuser host.dom 6432
=> \c service=foo
=> \c "host=localhost port=5432 dbname=mydb connect_timeout=10 sslmode=disable"
=> \c -reuse-previous=on sslmode=require    -- changes only sslmode
=> \c postgresql://tom@localhost/mydb?application_name=myapp
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.