I try to configure pgAgent on Windows server 2008 to make automatic backup on the database. pgAgent is installed on the server and the service is running normally. I use PgAdmin3 and PostgreSql 9.3

I have already planned query using the connection string with the password in it, and it works perfectly.

Now, I try to make it by specifying the password in pgpass.conf (as said in the doc) but I always got the "Couldn't get a connection to the database !" error.

My pgpass.conf is something like this :*:admin:****:postgres:***

I know that some line are rhetorical, it's just that I've tried a lot of things.

I usually try to connect on localhost, but even in remote connection mode it doesn't work.

Here some examples of what I've tried with remote connection in step configuration :

user=admin host= port=5432 dbname=db
user=postgres host= port=5432 dbname=db
user=admin host= port=5432 dbname=db
user=postgres host= port=5432 dbname=db

EDIT : in Postgres log, pgagent is connected as adminpostgres. This username isn't in the login role...

pgpass.conf is in c:/user/Application Data/postgresql

pgAgent was installed with StackBuilder as Admin

I've tried to fill the "host agent" field with the content of "pga_jobagent.jagstation" but it doesn't work either

  • Do you see (maybe in the Postgres logs) what exactly the error is? What you quote here does not come from the backend, I believe. – dezso May 13 '15 at 14:20
  • Nothing more interesting in the Postgres logs... There are only updates of the pgagent table for each error. But pgagent is connecting with the username 'adminpostgres' which is not logical (never saw this username before) – thofrancisco May 13 '15 at 14:43

I've found it !

In Windows Service, i found that it was "adminpostgres" who was running the pgAgent service.

I just had to edit the pgpass.conf in c:/user/adminpostgres/AppData/postgresql with my old config to make it works !


This answer was perfect! I found that the service was running under the Windows user postgres, so I went into that user's app data folder to the file (C:\Users\postgres\AppData\Roaming\postgresql\pgpass.conf), right-clicked and edited it with Notepad++, and added the line:


AND that was all that was needed to get rid of the error "Couldn't get a connection to the database!", and get on with having a running job.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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