How to tell rsyslog to use Unix domain sockets to write syslog messages to a Postgresql database?

I created a database as explained here:

I created a "root" user in the database and granted insert permissions:

Syslog=# create user "root";
Syslog=# grant insert on table SystemEvents to "root";
Syslog=# grant insert on table SystemEventsProperties to "root";

The connections works fine:

# psql Syslog -c 'conninfo'
You are connected to database "Syslog" as user "root" via socket in "/var/run/postgresql" at port "5432".

Then I tried several different ways to specify the host in the "rsyslog.conf":

*.* action(type="ompgsql" server="" db="Syslog" uid="root" pwd="")
*.* action(type="ompgsql" server="/run/postgresql" db="Syslog" uid="root" pwd="")
*.* action(type="ompgsql" server="/run/postgresql/.s.PGSQL.5432" db="Syslog" uid="root" pwd="")

Nothing works. I get always the error:

db error (1): no connection to the server [v8.2102.0]

How to fix this?

Asked By: ceving


The server action parameter should be a hostname or ip address, so try server="localhost" in
the first action. See the config


You can also try replacing all the parameters by a conninfo which uses a standard PostgreSQL URI format, for example:

action(type="ompgsql" conninfo="postgresql://root:@localhost/Syslog")

You shouldn’t need to specify the Unix domain socket, but the URI
documentation shows how you can do so, for example:

Answered By: meuh
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.