I am trying to connect to localHost on PG Admin but after entering all my server connection information, the window opened again and says:
Connection to DataBase failed
I already reinstall PostgreSQL 6 times with differents versions. I checked that the user Postgres exist, I modified pg_hba.conf by putting trust to the Postgres user. But it's still not working.
I am on Windows 10.
Using the version 9.4.5
Debug this like this:
Is PostgreSQL running? Check the Services! If not, start it. If there is no service, reinstall Postgres and check the appropriate options. If it is still not there, the installer is not Windows 10 ready. Create the service manually after reading the docs. Update: If you get a permission error when starting the service, a reason might be that the user created for the PostgreSQL service doesn't have the "Log on as a service" permission. You can grant it like described in this Microsoft Technet article.
Is the PostgreSQL port (default = 5432) open (Use netstat to check)? If not, check the postgresql.conf for the port. By default PostgreSQL listens only on localhost, not your external IP. Use "*" as the listen-IP in the PostgreSQL config, restart PostgreSQL.
If the port is open the error message should not appear. If it still does, check the logfiles. Use "trust" everywhere in your pg_hba temporarily to ensure this file is not the root of your problems.
SET path in environment variables [postgres bin]
set environment variable PGDATA <path_of_pgdata_folder> <== create it in postgres main folder
initdb.exe -D "C:\Users\<username>\Softwares\postgresql-9.6.14-1-windows-x64-binaries\pgsql\pgdata"
"pg_ctl" -D "C:\Users\<username>\Softwares\postgresql-9.6.14-1-windows-x64-binaries\pgsql\pgdata" -l logfile start
createuser -r postgres
now Open pgAdmin and connect to your database see image
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With