Postgres timesout on cloudflare:
I have a PG db at digital ocean, it works perfectly in my local machine, however when deployed on cf I get:
write CONNECT_TIMEOUT localhost:5432
which is weird as the port is not even 5432
.
This is a reprodution: https://github.com/cosbgn/pg-cloudflare/blob/main/server/api/test.js
This is where it times out: https://pg-cloudflare.pages.dev/api/test
Please DB me for the DB connection string and I'll share that. If someone has any idea on why it doesn't work on CF I would love it.
P.s. IP are unlocked on all location.10 Replies
What do you have the environment variable for
PG_URI
. It should be the postgres string of digtal oceanIt is
This is another example which also works perfectly on my machine but times out on cloudflare
GitHub
pg-cloudflare/server/api/psql.js at main · cosbgn/pg-cloudflare
Contribute to cosbgn/pg-cloudflare development by creating an account on GitHub.
@Cyb3r-Jok3
It looks like the environment variables aren't being set .Based on https://github.com/nuxt/nuxt/issues/25047 I think you need to expose the variables in the nuxtconfig
In the issue
However, I have never used nuxt so not 100% sure
GitHub
Cloudflare Pages Environment Variables not working · Issue #25047 ·...
Environment Cloudflare Pages Reproduction https://github.com/nicogenz/cf-pages-env-test Describe the bug When deploying a Nuxt3 project to Cloudflare Pages with default configuration, the environme...
Variables are 100% set, I tested also by hard coding directly the values in there
Then I don't know.
You saw this one already?
https://www.answeroverflow.com/m/1177687175375114300
When trying with Hyperdrive, have you tried connecting using the Hyperdrive binding's connection string? That should autopopulate correctly, and will prevent any oddities in manually passing the params.
Cloudflare Workers + Digital Ocean Managed Postgres DB - Cloudflare...
Hello, im trying to setup a simple JS POC using Cloudflare workers.
tl;dr the worker will query a Postgres DB on Digital Ocean. And i can not make it work at all.
I have tried both
pg
and postgres
javascript libraries
node_compat
is set to true
```
import { Client } from "pg";
const client = new Client({
connectionString: "postgresq...I've found a good bit of successful usage of Hyperdrive with origins on DigitalOcean, so there's nothing fundamentally broken about the interactions between the two.
hyperdrive is not available on pages so I wouldn't work.
I tried also locally with wrangler dev and it just can't connect and I also tried with another PG provider, same thing.
Not sure, but it could be caused by nuxt
If someone would like to help out this can be run also locally (and it will timeout also locally) with:
NITRO_PRESET=cloudflare_module npm run build
and then:
npx wrangler dev --remote .output/server/index.mjs --site .output/public --log-level debug
Happy to share the DB password for a suuuper simple reproduction
If anyone could even be able to tell me if the issue is on cloudflare side or nuxt side it would already be a big help