Skip to content
This repository was archived by the owner on Oct 29, 2025. It is now read-only.
This repository was archived by the owner on Oct 29, 2025. It is now read-only.

Can't get build to connect to postgres #134

Closed

Description

@moekify

I verified that the connection works with pg_isready, however during the build step it fails to connect to localhost (and the provided db url)

@calcom/prisma:build: Prisma schema loaded from schema.prisma
@calcom/prisma:build: Datasource "db": PostgreSQL database "calcom", schema "public" at "localhost:5432"
@calcom/prisma:build: 
@calcom/prisma:build: Error: P1001: Can't reach database server at `localhost`:`5432`
@calcom/prisma:build: 
@calcom/prisma:build: Please make sure your database server is running at `localhost`:`5432`.
@calcom/prisma:build: error Command failed with exit code 1.
@calcom/prisma:build: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@calcom/prisma:build: error Command failed with exit code 1.
@calcom/prisma:build: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any hints? I spent quite some time to debug this

Activity

  1. finaldzn commented on Jun 22, 2022

    @finaldzn

    Is Postgres in the same container as cal.com ? If not then your postgresql instance is not reachable on local host.

    Do you have a docked-compose or something like that ?

  2. krumware commented on Jun 22, 2022

    @krumware
    Contributor

    Localhost to the container, during the build, is the container itself and not your local development machine.

    The docker compose build steps are provided because it creates a network bridge which allows you to reference a postgres container to build against.

    It's worth mentioning that the build does not need to reference the same database as it will reference in runtime.

  3. brunoamaral commented on Jun 23, 2022

    @brunoamaral

    I'm having the same issue, but in my case I had setup container_name: database on docker-compose.yaml and the build still fails. Also tried to replace the container name for the IP and it also fails.

    #0 8.862 @calcom/prisma:db-deploy: Error: P1001: Can't reach database server at `172.20.0.2`:`5432`
    #0 8.862 @calcom/prisma:db-deploy:
    #0 8.863 @calcom/prisma:db-deploy: Please make sure your database server is running at `172.20.0.2`:`5432`.
    #0 8.896 @calcom/prisma:db-deploy: error Command failed with exit code 1.
    #0 8.896 @calcom/prisma:db-deploy: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    #0 8.926 @calcom/prisma:db-deploy: error Command failed with exit code 1.
    #0 8.926 @calcom/prisma:db-deploy: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    #0 8.939 @calcom/prisma:db-deploy: ERROR: command finished with error: command (packages/prisma) yarn run db-deploy exited (1)
    #0 8.959 command (packages/prisma) yarn run db-deploy exited (1)
    #0 8.959
    #0 8.959  Tasks:    2 successful, 3 total
    #0 8.960 Cached:    1 cached, 3 total
    #0 8.960   Time:    8.208s
    #0 8.960
    #0 8.994 error Command failed with exit code 1.
    #0 8.995 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    ------
    failed to solve: executor failed running [/bin/sh -c yarn build]: exit code: 1
    
  4. moekify commented on Jun 23, 2022

    @moekify
    Author

    It didn't work using the default network created by compose. However, once I added a dedicated network it worked out by running the container on its own. FWIW, I have it running behind a reverse proxy (traefik) that requires my own custom docker-compose setup.

  5. brunoamaral commented on Jun 27, 2022

    @brunoamaral

    @moekify what do you mean by a dedicated network? As far as I know, the one in docker-compose is already shared by the three containers.

  6. moekify commented on Jun 27, 2022

    @moekify
    Author

    @brunoamaral I wrote my own docker-compose as I have a lot of custom properties for traefik (reverse-proxy) to work correctly with calcom :) I usually use the default network that gets created by docker-compose instead of specifying a new network inside the compose file. However, with the default network it didn't work in calcoms case. Why, I don't know 🤷

  7. self-assigned this
    on Jul 18, 2022
  8. lakmal-ya commented on Dec 14, 2024

    @lakmal-ya

    I encountered the same issue on Ubuntu 20.04.1 LTS (Focal Fossa). Here's the system information for reference:

    NAME="Ubuntu"
    VERSION="20.04.1 LTS (Focal Fossa)"
    ID=ubuntu
    ID_LIKE=debian
    PRETTY_NAME="Ubuntu 20.04.1 LTS"
    VERSION_ID="20.04"
    HOME_URL="https://www.ubuntu.com/"
    SUPPORT_URL="https://help.ubuntu.com/"
    BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
    PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    VERSION_CODENAME=focal
    UBUNTU_CODENAME=focal
    

    The issue was that Docker had been installed via Snap. To resolve it, I removed the Snap version of Docker and reinstalled it using apt. Here’s the command I used:

    sudo apt install docker.io

    After reinstalling Docker with this method, the issue was resolved.

  9. krumware commented on Jul 21, 2025

    @krumware
    Contributor

    Closing for cleanup. This may be addressed by incoming updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions