Skip to content

[Bug]: Wrong destination when creating a database with API #6972

@W8jonas

Description

@W8jonas

Error Message and Logs

I encountered an error in the PostgreSQL database creation API.

In my context, I have several destinations and need to create databases programmatically via the API. I noticed that every database created always ends up in the server's first destination.

Steps to Reproduce

  1. Create 2 destinations in UI.
  • First one is: name: _2_a_new_test, docker network: _2_a_new_test and uuid (in the url): bk8cw0gkswgo04o0s88sk0kg;
  • Second one is: name: _2_b_new_test, docker network: _2_b_new_test and uuid (in the url): rowwocok08sgg800ogkogkc4;
  1. Call API to create a new Postgresql database:
curl 'https://<HOST>/api/v1/databases/postgresql' \
  --request POST \
  --header 'Authorization: Bearer <TOKEN>' \
  --header 'Content-Type: application/json' \
  --data '{
  "server_uuid": "h4ooscogk0o4k8wo8sk0cow0",
  "project_uuid": "vsogw8ss4ww8oos8gcg8okog",
  "environment_name": "production",
  "destination_uuid": "rowwocok08sgg800ogkogkc4",
  "instant_deploy": false
}'

{
  "uuid": "w4w4gsocg8gco0sog8wk04wo",
  "internal_db_url": "postgres://postgres:password@w4w4gsocg8gco0sog8wk04wo:5432/postgres"
}
  1. The database was created in the first destination "_2_a_new_test".
curl 'https://<HOST>/api/v1/databases/w4w4gsocg8gco0sog8wk04wo' \
  --request GET \
  --header 'Authorization: Bearer <TOKEN>' \
  --header 'Content-Type: application/json'

{
  "uuid": "w4w4gsocg8gco0sog8wk04wo",
  "name": "postgresql-database-w4w4gsocg8gco0sog8wk04wo",
  "config_hash": "e02ce91ef42f76ae182ae2212b9cee95",
  "database_type": "standalone-postgresql",
  "destination": {
    "id": 43,
    "name": "_2_a_new_test",
    "uuid": "bk8cw0gkswgo04o0s88sk0kg",
    "network": "_2_a_new_test",
    "server_id": 1,
    "created_at": "2025-10-23T00:22:16.000000Z",
    "updated_at": "2025-10-23T00:22:16.000000Z",
    "server": {
      "id": 1,
      "uuid": "h4ooscogk0o4k8wo8sk0cow0",
      "name": "server2",
      "description": "",
      ...
    }
  }
}
  1. Note that the database was created in the wrong destination. The same occurs when environment_uuid is passed instead of environment_name.

Example Repository URL

No response

Coolify Version

v4.0.0-beta.434

Are you using Coolify Cloud?

No (self-hosted)

Operating System and Version (self-hosted)

No response

Additional Information

For more context, i have 2 servers, but i dont think that matters

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✅ DoneIssues that are fixed and a PR is ready to be merged.🐞 Confirmed BugVerified issues that have been reproduced by the team.🔍 TriageIssues that need assessment and prioritization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions