AAA
AAA

Reputation: 364

Cannot connect to the database in PostgreSQL

Terminal shows you are connected to database. While sending request from Postman it shows:

Cannot connect to database [default].

I have tried different solutions provided in Stack Overflow but it still doesn't work.

What I have done:

db{
107  default.driver=org.postgresql.Driver
108  default.url="jdbc:postgresql://localhost:5432/student"
109  default.user=postgres
110  default.password=root

And this is what I have done in Terminal is:

createdb -h localhost -p 5432
postgres student password root

Upvotes: 1

Views: 7128

Answers (2)

AAA
AAA

Reputation: 364

This works:

postgres=# sudo -u postgres psql postgres

postgres-# \password postgres

Enter new password: 

Enter it again: 

In my case password is root as I have keep my default password as root.

Upvotes: 1

When I get some kind of PostgreSQL connection error the

  1. first step I take is to test if `psql' works by using the following command

    $ psql -d mypgdatabase -U mypguser
  2. If this doesn't give us a clue then the second step is to see if `pg_hba.conf' file has correct permission for our user, for example it should contain a like like this

    local   all         all                               trust

    After editing this file don't forget to reload postgresql service by issuing the following command

    $ sudo /etc/init.d/postgresql reload

    Now try again step 1.

This is all beautifully documented in Debian PostgreSQL wiki page here https://wiki.debian.org/PostgreSql

Upvotes: 1

Related Questions