coolify icon indicating copy to clipboard operation
coolify copied to clipboard

[Bug]: Error Encountered When Adding Custom PostgreSQL Configuration

Open hamedyosefian opened this issue 1 year ago • 5 comments

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

  1. Open the PostgreSQL service.
  2. Add a custom PostgreSQL configuration.
  3. Restart the service.
  4. 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

hamedyosefian avatar Dec 09 '24 06:12 hamedyosefian

Same issue here, you cannot create any custom config this way from Coolify

PolpOnline avatar Dec 11 '24 23:12 PolpOnline

+1

zaosoula avatar Nov 23 '25 15:11 zaosoula

any workaround?

GottZ avatar Dec 09 '25 07:12 GottZ

Image

this did the trick for me within the host system. any idea why the permission for this configuration file exposed via Image

doesn't get the correct permissions? maybe umask?

GottZ avatar Dec 09 '25 09:12 GottZ

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.

GottZ avatar Dec 09 '25 09:12 GottZ

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:

  1. Deploy or restart the PostgreSQL container with the custom configuration already included
  2. Access the host machine terminal (via Coolify terminal or SSH)
  3. Run: sudo chmod 755 /data/coolify/databases/<your_service_uid>/custom-postgres.config
  4. (Optional) Restart your PostgreSQL container again

How to find your PostgreSQL service UID if you've renamed the service:

  1. Access the service logs
  2. The UID will be shown in the header

Reference: Originally reported by @GottZ in #4519

Obs It worked for me too !

gabrielfmcoelho avatar Dec 16 '25 11:12 gabrielfmcoelho