Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error connect database #88

Open
zevsdflkjiuxcvb opened this issue Jun 23, 2022 · 9 comments
Open

Error connect database #88

zevsdflkjiuxcvb opened this issue Jun 23, 2022 · 9 comments

Comments

@zevsdflkjiuxcvb
Copy link

Have you experienced this bug with the latest version of the template?

yes

Steps to Reproduce

Run npx create-remix --template remix-run/blues-stack in console
then npm run dev, I get this error
Here is my db URL in .env file: DATABASE_URL="postgresql://postgres:norqgrhigqygxsywkasp@db.norqgrhigqygxsywkasp.supabase.co:5432/postgres"

app ready: http://localhost:3000
(node:9388) UnhandledPromiseRejectionWarning: Error: Can't reach database server at `undefined.db.norqgrhigqygxsywkasp.supabase.co`:`5432`

Please make sure your database server is running at `undefined.db.norqgrhigqygxsywkasp.supabase.co`:`5432`.
    at D:\job\test\remix-blue\node_modules\@prisma\client\runtime\index.js:44801:20
(Use `node --trace-warnings ...` to show where the warning was created)
(node:9388) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9388) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Expected Behavior

Just hope plug and run :(

Actual Behavior

image

@mcansh
Copy link
Contributor

mcansh commented Jun 23, 2022

did you opt out of installing dependencies during "create-remix"? if not, a .env file should have been generated for you during "remix init" with the contents of .env.example https://github.com/remix-run/blues-stack/blob/main/remix.init/index.js#L63

if you do opt out, you should be seeing the following which prompts you to install your dependencies and run "npx remix init"

@machour machour added the needs-response We need a response from the original author about the issue label Jun 23, 2022
@mcansh
Copy link
Contributor

mcansh commented Jun 24, 2022

ah actually, re-read your issue, looks like the DB url the app has isn't correct (see undefined)

@zevsdflkjiuxcvb
Copy link
Author

undefined

Yeah I know, but why? I should be ran, right ?

@mcansh
Copy link
Contributor

mcansh commented Jun 29, 2022

what's weird is there is no subdomain before .db.nor... so im not sure where the undefined is even coming from

@machour machour removed the needs-response We need a response from the original author about the issue label Jul 11, 2022
@juanmcampos
Copy link

juanmcampos commented Jul 20, 2022

It seems to come from db.server.ts file there is a conditional if (!isLocalHost) { } which sets the databaseurl for FLY_REGION which if you are not using and you are not localhost then it breaks.

@juanmcampos
Copy link

I made a PR with a quick fix :P maybe not the best solution but hope it helps #101

@phifa
Copy link

phifa commented Dec 20, 2022

I just ran into the same issue. It's not fixed, is it?

@machour
Copy link
Collaborator

machour commented Dec 20, 2022

@phifa if the issue is still open then most likely not. Check the pull request #101 and if it works for you, then comment there to validate it and get this fixed 👍

@tylerdukedev
Copy link

tylerdukedev commented Apr 3, 2023

UPDATE:

~~Anyone find a solution for this? I'm running in to the same issue. I've altered my db.server file to something more generic:

import { PrismaClient } from "@prisma/client";

let db: PrismaClient;

declare global {
  var db: PrismaClient | undefined;
}

// PrismaClient is attached to the `global` object in development to prevent
// exhausting your database connection limit.
if (process.env.NODE_ENV === "production") {
  db = new PrismaClient();
  db.$connect();
} else {
  if (!global.db) {
    global.db = new PrismaClient();
    global.db.$connect();
  }

  db = global.db;
}

export default db;

Still doesn't work.~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants