How to fix a Can't reach database server at `.postgres.database.azure.com`:`5432` error

Philip Mutuku 20 Reputation points
2024-01-22T12:37:47.23+00:00

hey am getting an error when querying the postgre flexible database below is the error { "errors": [ { "message": "\nInvalid prisma.users.create() invocation:\n\n\nCan't reach database server at [http://stocksync.postgres.database.azure.com](https://t.co/EsOl7vZhmj):5432\n\nPlease make sure your database server is running at [http://stocksync.postgres.database.azure.com](https://t.co/EsOl7vZhmj):5432.", "locations": [ { "line": 2, "column": 3 } ], "path": [ "addUser" ], "extensions": { "code": "INTERNAL_SERVER_ERROR", "exception": { "name": "PrismaClientInitializationError", "clientVersion": "5.7.1" } } } ], "data": { "addUser": null } } additional information it works well in localhost but after i hosted it to https://stocksync-server.onrender.com it gives the error. am using postman to test it

Cloning from https://github.com/Musyonchez/StockSync-Server
==> Checking out commit b7a1ff9b5641c5f29f7ef89ea03b37b62e4beb0d in branch main
==> Downloading cache...
==> Transferred 105MB in 7s. Extraction took 2s.
==> Requesting node version 18.5
==> Using Node version 18.5.0 via environment variable NODE_VERSION
==> Docs on specifying a Node version: https://render.com/docs/node-version
==> Running build command 'yarn install'...
yarn install v1.22.21
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
warning apollo-server-express > apollo-server-types@3.8.0: The `apollo-server-types` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/server` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.
warning apollo-server-express > apollo-server-core > apollo-server-types@3.8.0: The `apollo-server-types` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/server` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.
warning apollo-server-express > apollo-server-types > apollo-reporting-protobuf@3.4.0: The `apollo-reporting-protobuf` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/usage-reporting-protobuf` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.
warning apollo-server-express > apollo-server-core > apollo-reporting-protobuf@3.4.0: The `apollo-reporting-protobuf` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/usage-reporting-protobuf` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.
warning apollo-server-express > apollo-server-types > apollo-server-env@4.2.1: The `apollo-server-env` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/utils.fetcher` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.
warning apollo-server-express > apollo-server-core > apollo-server-env@4.2.1: The `apollo-server-env` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/utils.fetcher` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.
warning apollo-server-express > apollo-server-core > apollo-datasource@3.3.2: The `apollo-datasource` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.
warning apollo-server-express > apollo-server-core > apollo-datasource > apollo-server-env@4.2.1: The `apollo-server-env` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/utils.fetcher` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.
warning apollo-server-express > apollo-server-core > apollo-server-errors@3.3.1: The `apollo-server-errors` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/server` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.
warning apollo-server-express > apollo-server-core > apollo-server-plugin-base@3.7.2: The `apollo-server-plugin-base` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/server` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.
warning apollo-server-express > apollo-server-core > apollo-server-plugin-base > apollo-server-types@3.8.0: The `apollo-server-types` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/server` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.
warning tslint@6.1.3: TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 14.24s.
==> Uploading build...
==> Build uploaded in 8s
==> Build successful 🎉
==> Deploying...
==> Requesting node version 18.5
==> Using Node version 18.5.0 via environment variable NODE_VERSION
==> Docs on specifying a Node version: https://render.com/docs/node-version
==> Running 'npm start'
> server@1.0.0 start
> ts-node src/server.ts
Persisted queries are enabled and are using an unbounded cache. Your server is vulnerable to denial of service attacks via memory exhaustion. Set `cache: "bounded"` or `persistedQueries: false` in your ApolloServer constructor, or see https://go.apollo.dev/s/cache-backends for other alternatives.
Server is running at http://localhost:10000/graphql                                                      mutation {
  addUser(
    firstName: "John"
    lastName: "Doe"
    age: 25
    email: "john.doe@example.com"
    password: "password123"
    store1: true
    store2: false
    store3: true
    store4: false
    company: "addermatt"
    type: "users"
  ) {
    id
    firstName
    lastName
    age
    email
    password
    store1
    store2
    store3
    store4
  }
}  
Azure Database for PostgreSQL
{count} votes

Accepted answer
  1. GeethaThatipatri-MSFT 27,337 Reputation points Microsoft Employee
    2024-01-24T17:29:26.7533333+00:00

    Hi,@Philip Mutuku I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue: You are getting an error when querying the Postgres flexible database. The error message indicates that the database server cannot be reached.

    Solution: As you mentioned Yes, it is possible that the IP address access restriction was set to your machine during development, and that's why there was no problem. Updating the IP address access restriction in Azure to the correct IP address resolved the issue.

    If you have any other questions or are still running into more issues, please let me know.
    Thank you again for your time and patience throughout this issue.

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    Regards

    Geetha

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Philip Mutuku 20 Reputation points
    2024-01-24T05:09:11.5633333+00:00

    The ip address access restriction was set to my machine so during development there was no problem but after hosting it was a problem. So just update the ip address in azure.

    0 comments No comments