PostgreSQL : FATAL: could not open log file “/path/to/log/filesystem/postgresql-Sun.log”: No such file or directory

postgresqlpostgresql-11

I am new to PostgreSQL and stuck on an issue that PostgreSQL isn't starting up. It reported:

FATAL: could not open log file "/path/to/log/filesystem/postgresql-Sun.log": No such file or directory
06:52:32.530 UTC [7440] LOG: database system is shut down

I tried to find the solution online and changed the permission of the postgres user using chown, but that also didn't help or maybe I missed something.

Please advise.

Best Answer

User, which runs postgresql, often postgres, must be able to traverse to this /path/to/log/filesystem/ (often /var/log/postgresql), specified by log_directory config option and be able to write files there. If this path does not exist, you will get No such file or directory error.

You can try switching to this user (e.g. su postgres) and check cd /path/to/log/filesystem (whatever this path really is) and if that throws error, then create the directories (e.g. mkdir -p /path/to/your/log_directory).

There's also a possibility that service manager changes mount points for the service, like systemd is capable of.