[Bug]: Error Encountered When Adding Custom PostgreSQL Configuration
Error Message and Logs
I am encountering an issue when attempting to add a custom configuration to an existing PostgreSQL database. When I try to apply the configuration and restart the service, the following error occurs, and the service becomes unhealthy.
PostgreSQL Database directory appears to contain a database; Skipping initialization
PostgreSQL Database directory appears to contain a database; Skipping initialization
2024-12-01 14:23:26.563 GMT [1] LOG: could not open configuration file "/etc/postgresql/postgresql.conf": Permission denied
2024-12-01 14:23:26.563 GMT [1] FATAL: configuration file "/etc/postgresql/postgresql.conf" contains errors
2024-12-01 14:23:27.725 GMT [1] LOG: could not open configuration file "/etc/postgresql/postgresql.conf": Permission denied
2024-12-01 14:23:27.725 GMT [1] FATAL: configuration file "/etc/postgresql/postgresql.conf" contains errors
2024-12-01 14:23:28.890 GMT [1] LOG: could not open configuration file "/etc/postgresql/postgresql.conf": Permission denied
Steps to Reproduce
- Open the PostgreSQL service.
- Add a custom PostgreSQL configuration.
- Restart the service.
- Check the logs for errors; the service is reported as unhealthy.
Example Repository URL
No response
Coolify Version
v4.0.0-beta.373
Are you using Coolify Cloud?
No (self-hosted)
Operating System and Version (self-hosted)
No response
Additional Information
When create new postgresql service that okay this problem just database from prev exist
Same issue here, you cannot create any custom config this way from Coolify
+1
any workaround?
this did the trick for me within the host system.
any idea why the permission for this configuration file exposed via
doesn't get the correct permissions? maybe umask?
https://github.com/coollabsio/coolify/blob/b7282ad565376ac3efcc70c8ca383b765cc79b2b/app/Actions/Database/StartPostgresql.php#L331
so.. this line creates the config file.. I suspect umask limits it to 700 so.. I suspect someone more knowledgeable about this repo could easily one-line fix this issue.
also.. creating custom files in the volume section also makes them 700.
Context: In Coolify 4.0.0, you can add custom PostgreSQL configuration variables through the "Custom PostgreSQL Configuration" field. This field is essentially a shortcut that creates the file /data/coolify/databases/<your_service_uid>/custom-postgres.config. However, when deploying or restarting the container with custom configuration, the logs return:
PostgreSQL Database directory appears to contain a database; Skipping initialization
2024-12-01 14:23:26.563 GMT [1] LOG: could not open configuration file "/etc/postgresql/postgresql.conf": Permission denied
2024-12-01 14:23:26.563 GMT [1] FATAL: configuration file "/etc/postgresql/postgresql.conf" contains errors
Temporary Workaround:
- Deploy or restart the PostgreSQL container with the custom configuration already included
- Access the host machine terminal (via Coolify terminal or SSH)
- Run:
sudo chmod 755 /data/coolify/databases/<your_service_uid>/custom-postgres.config - (Optional) Restart your PostgreSQL container again
How to find your PostgreSQL service UID if you've renamed the service:
- Access the service logs
- The UID will be shown in the header
Reference: Originally reported by @GottZ in #4519
Obs It worked for me too !