1

Why I can open the database from pgAdmin 3 but when I tried it on laravel, it doesn't working?

It Gives me this error

SQLSTATE[08006] [7] FATAL: password authentication failed for user "khrisna" FATAL: password authentication failed for user "khrisna"

I already tried this method by adding my own postgresql user

enter image description here

Here is the proof that my pgAdmin accept my user and password, I even added new "server" to make sure that my credentials are correct

enter image description here

So why in the laravel it says it wrong? Here is my .env file

enter image description here

EDITED:

I just realized, that I can run php artisan migrate without problems, so why the only problem is to access the database? I already hit the wall and don't know what to do or even I don't know what kind of keywords I need to type into google to get the answer.

  • Have u checked the port number – Jigs1212 Mar 17 '18 at 05:12
  • try port 5433 in .env – Jigs1212 Mar 17 '18 at 05:15
  • @Jigs1212 Yes, I already checked the port number, you can see it on pgAdmin screenshot, that `5432` is working – Khrisna Gunanasurya Mar 17 '18 at 05:21
  • Indeed it's not the port. "Password authentication failed" is an error from the postgresql server. So you actually have a connection to the database server but it is not letting you proceed further because something isn't right with the username password combination. – Eelke Mar 17 '18 at 06:23
  • @Eelke yeah that's true, but the problem is it's not working only on laravel, as you can see I can connect to my postgresql server without problem on pgAdmin, that's why I don't know why is this happening – Khrisna Gunanasurya Mar 17 '18 at 06:28
  • @Eelke hi, it turns out I can run `php artisan migrate` without any errors, so why it's only happened when I tried to get data from the database? – Khrisna Gunanasurya Mar 17 '18 at 07:59
  • Post the relevant code you use for retrieving data. – Eelke Mar 17 '18 at 08:03
  • @Eelke I already did that, I already change the user password several times, this is the file content `localhost:5432:*:postgres:rootroot`, I changed the owner of the database to the default one, and I already change it on `.env` file as well. but it's still the same error I got – Khrisna Gunanasurya Mar 17 '18 at 08:04
  • @Eelke It's the default code, from login and register laravel features `php artisan make:auth`, and I haven't change anything – Khrisna Gunanasurya Mar 17 '18 at 08:06
  • @KhrisnaGunanasurya did you figure this out? I've ran into the same issue. Postico has no issues connection. When I login to psql via terminal, it asks for a password and has no problem connecting. Only Laravel can't seem to use the password correctly. – SegFaultDev Sep 18 '18 at 16:30
  • @SegFaultDev sorry, i can’t figure this out, so I use the mysql instead. Maybe there’s a problem with laravel 5.6, maybe you can try using laravel 5.7.*? – Khrisna Gunanasurya Sep 19 '18 at 00:49

1 Answers1

0

I was having a similar problem because I was using Homestead, so the localhost address was pointing to the virtual machine, not my computer. Changing the IP address to MY IP address worked. Or else just use the Laravel default who's user name is homestead and password is secret. It accesses Postres as a local instance on the virtual machine

mar
  • 11
  • 1
  • 2