I'm trying to reset my lost password for Postgres v9.1 (windows 7) like written at https://wiki.postgresql.org/wiki/FAQ#I_lost_the_database_password._What_can_I_do_to_recover_it.3F :

1. edit pg_hba.conf to allow trust authorization temporarily

In pg_hba.conf I've put :

local all all trust

host all all trust

2. Reload the config file (pg_ctl reload)

Done. I have also restarted the Postgres service (via services.msc)

3. Connect and issue ALTER ROLE / PASSWORD to set the new password

Then I execute 'psql.exe' but it asks me for a password !

Why ? Thanks for your help.

  • You put the new pg_hba.conf entries at the end, so the other ones take priority. Put them at the start. Nov 13, 2015 at 2:21
  • The entries are already at the beginning of the file
    – Jeremy
    Nov 13, 2015 at 18:12
  • Are you sure you edited the right pg_hba.conf file? or connecting to the right PostgreSQL instance?
    – dezso
    Dec 16, 2015 at 10:04

1 Answer 1


Try to run psql -h (...)

When you use the -h that will tell psql to use a TCP/IP connection ('h' is from host), and the parameter after -h is the name of the host.

In that case is a default address, meaning localhost.

If you don't use the -h (with host next to this parameters) it will use a "local way" of connection called unix domain sockets.

  • 1
    The OP is on Windows, so there is no socket, unfortunately.
    – dezso
    Dec 16, 2015 at 10:02
  • Using -h and -u helps me to resolve this issue, thanks.
    – Jeremy
    Dec 21, 2015 at 9:27
  • I'm confused though because his question shows he had host all all trust that should be triggering with -h and as @dezso said, mswin doesn't have sockets. Mar 9, 2017 at 20:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.