2

I am running Postgres 9.3 on Ubuntu 14.04 and I am unable to get pgAgent daemon/service to run.

I have confirmed that the daemon is not running using service --status-all.

When trying to run pgagent (whilst logged in as the only user in ubuntu) using pgagent hostaddr=127.0.0.1 dbname=postgres user=user1 the following messages are displayed:

WARNING: Couldn't create the primary connection (attempt 10): fe_sendauth: no password supplied

ERROR: Stopping pgAgent: Couldn't establish the primary connection with the database server.

The lack of running pgAgent was also confirmed when trying to run a job on demand.

The user 'user1' is able to log into pgAgmin and connect to the database from other computers on the local network.

The user looks like this in the pg_hba.conf file:

# Database administrative login by Unix domain socket
local   all             user1                                md5

A .pgpass password file also exists for this user in the home directory.

What is causing the above messages and what needs to be done to get pgAgent to run scheduled tasks?

4
  • 1
    The question boils down to: why is .pgpass getting ignored? Wrong permissions is a common reason. Nov 29 '15 at 16:50
  • Worked our why .pgpass is getting ignored. The home directory is encrypted at boot up. In order to get the command to work, I need to ssh in and unencrypt the home directory. Would creating a separate user (in linux and postgres) for pgagent and having a separate .pgpass file in that users directory be likely to resolve this? Or maybe even moving the .pgpass file somewhere else where it is not encrypted at startup?
    – Greg
    Nov 30 '15 at 2:17
  • 1
    See libpq environment variables. That indicates how to put .pgpass elsewhere but also that you might avoid it altogether, and use PGPASSWORD instead. Nov 30 '15 at 8:28
  • @DanielVérité a bit late but I think I found that what you say is true, and a possible reason why it's being ignored (posted answer)
    – DarkCygnus
    Jan 27 '20 at 19:08
0

Late answer but...

What is causing the above messages and what needs to be done to get pgAgent to run scheduled tasks?

Seems that, as stated in comments, this boils down to why the .pgpass file is being ignored.

Reading the documentation I found the following relevant details on this page, emphasis mine:

On Unix systems, the permissions on a password file must disallow any access to world or group; achieve this by a command such as chmod 0600 ~/.pgpass. If the permissions are less strict than this, the file will be ignored. On Microsoft Windows, it is assumed that the file is stored in a directory that is secure, so no special permissions check is made.

So, if your .pgpass file does not have such permissions it will be ignored. This could be what is causing the error you see.

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.