Skip to content

[Bug] Postgres-meta Hardcoded Connection Alias 'db' Causes Port Mismatch with External DB #1020

@lqh19870820

Description

@lqh19870820

Labels: bug, self-hosted, postgres-meta, external-db

Description
We are using a self-hosted Supabase setup with an external PostgreSQL database running on a non-standard port (5632).

The issue arises when invoking API endpoints that route through the supabase-meta service (e.g., /api/platform/pg-meta/default/query). The service fails to use the explicitly configured environment variables (PG_META_DB_HOST, PG_META_DB_PORT, or even the full PG_META_DB_URL) and instead defaults to a hardcoded connection alias.

Observed Behavior
Configuration: The supabase-meta container is configured with the correct external connection details in docker-compose.yml:

YAML

meta:
image: supabase/postgres-meta:v0.93.0
environment:
# Correctly pointing to the external DB IP and Port 5632
PG_META_DB_URL: postgres://user:[email protected]:5632/postgres
# ... other PG_META_DB_ variables set correctly ...
Error during API call: The service attempts to connect using an internal alias:

JSON

{"error":{"code":"ENOTFOUND","message":"getaddrinfo ENOTFOUND db"} ... "pg":"db"}
(Note: The ENOTFOUND db error was temporarily fixed by adding extra_hosts: ["db:192.168.2.130"]).

Core Problem: After resolving db to 192.168.2.130 using extra_hosts, the connection attempt is made to 192.168.2.130:5432 (the default PostgreSQL port), ignoring the configured 5632 port from PG_META_DB_URL.

Confirmed Code Behavior: Diagnostics show the explicit PG_META_DB_HOST and PG_META_DB_PORT variables are being ignored by the query routing logic, confirming that the service is prioritizing a hardcoded connection alias (db) over standard environment variables for certain internal routes.

Expected Behavior
The postgres-meta service should respect the connection details provided in the PG_META_DB_URL (or PG_META_DB_PORT) for its primary connection pool, regardless of the internal connection alias used by the API router. The successful connection should be established on 192.168.2.130:5632.

Suggested Fix / Request
We request that the postgres-meta routing logic be updated to:

Prioritize the full connection string specified in PG_META_DB_URL for all internal connection pools (including the one mapped to db or default).

If an internal alias (db) is used, ensure it inherits the port information from the primary connection configuration (PG_META_DB_PORT) and does not revert to the default 5432.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions