4

I've installed pgAgent with the Windows service using a local machine account called postgres. I have confirmed that the Windows service is running normally. I created a job in pgAdmin that should delete certain records from a table in my customer DB. The only step in the job is configured with a Local connection type to the customer DB. The problem is, the job fails every time with the following warning written to the Windows event log:

Failed to create new connection to database 'customer':'fe_sendauth: no password supplied'

I have verified that there is a pgpass.conf file located in C:\Users\postgres\AppData\Roaming\postgresql. Here are its contents:

localhost:5432:postgres:postgres:<password_redacted>

I am not sure what else to try. I have been unable to locate any further information about this error message as it applies to pgAgent.

Version information:

  • PostgreSQL 9.2.4, compiled by Visual C++ build 1600, 64-bit
  • pgAdmin 1.16.1
  • pgAgent v3.3.0-1

Windows service startup information:

C:\Program Files (x86)\pgAgent\bin\pgagent.exe RUN pgAgent host=localhost port=5432 user=postgres dbname=postgres

Non-comment contents of pg_hba.conf:

host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5
NathanAldenSr
  • 7,841
  • 4
  • 40
  • 51
  • You forgot top mention your Postgres and pgAdmin versions. Anything in DB log? What's in your `pg_hba.conf`. Does reading [this related answer](http://stackoverflow.com/questions/15359348/run-batch-file-with-psql-command-without-password/15593100#15593100) help (the part about Windows in particular)? – Erwin Brandstetter Apr 07 '13 at 20:38
  • Added as requested. Also, the other article deals with psql.exe so the problems aren't quite the same. The fact that this is a Windows service makes it harder to debug IMO. – NathanAldenSr Apr 07 '13 at 21:03
  • I wonder if this has something to do with localhost vs. local? Even if so, I'm still not sure exactly what must be changed. – NathanAldenSr Apr 07 '13 at 21:15
  • Normally, the DB log files have additional details about failed login attempts. Maybe you are trying to connect with different user? Or `pgpass.conf` doesn't have the right permissions? – Erwin Brandstetter Apr 07 '13 at 22:34
  • I did check the permissions on the file and yes, the `postgres` Windows user has Full Control rights over the file. I also verified with Process Monitor that the file was actually being opened and read by pgagent.exe. I checked the DB log files and the only thing they said was that the connection attempt failed. – NathanAldenSr Apr 08 '13 at 00:08
  • In the meantime, I decided to write a .NET console application that I will use to schedule SQL execution. – NathanAldenSr Apr 08 '13 at 00:09

3 Answers3

2

What I did was under the step of the job in PgAgentIII

I changed the Connection Type To Remote
Set the Connection String with the button ...
changed the user=postgres to my apps user name
added password=PASSWORD (fill in your password)
change the host=127.0.0.1

I no longer get the error

Cœur
  • 37,241
  • 25
  • 195
  • 267
Teniosoft
  • 21
  • 3
0

I've bumped into the same problem with pgAgent job step configured for local connection:
Failed to create new connection to database '<database_name>':'fe_sendauth: no password supplied'

Solution with putting password into connection string works fine, but seems insecure.

After digging around I've found another solution - adding connection string to pgpass.conf for step's target database solve the issue:
localhost:5432:<database_name>:postgres:<password>

Eugene
  • 1,435
  • 1
  • 10
  • 4
-1

Make sure to check that the username the pgadmin service and the username of the pgpass.conf file you are checking match. I had the same problem until I realized the pgadmin installer had set the service to run as a local user, and I was checking the pgpass.conf for the same username as a domain user.