W
Waspβ€’5mo ago
CamBlackwood

Getting network errors when trying to authenticate when running app with remote database locally

I'm currently trying to test out some functionality locally that requires using the production database - I'm proxying requests to to a localhost port and can access the right data for sure (I can see it when I run wasp db studio) The specifc error I get is "ERR_CONNECTION_REFUSED"
9 Replies
kapa.ai
kapa.aiβ€’5mo ago
Hi @CamBlackwood. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the knowledge sources provided, it seems like you might be experiencing a similar issue to the one described in Github Issue #460 (https://github.com/wasp-lang/wasp/issues/460). The error message "ERR_CONNECTION_REFUSED" typically indicates that the application is unable to establish a connection to the database. Here are a few things you could check: 1. Database URL: Ensure that the DATABASE_URL in your .env.server file is correctly set. If it's not set or incorrect, it could lead to connection issues. 2. Database Connection: Test the connection to your database by running wasp db studio. If it connects, the connection works. If it fails to connect at all, it might be that you forgot to set DATABASE_URL in the .env.server file, or that the value in DATABASE_URL is incorrect (password? database name?), or that something else is running already on the port 5432. 3. Database Seeding: If you're trying to populate your production database, you can use the wasp db seed command. However, be careful with this as it could potentially overwrite data. 4. Cleanup: After you're done, remember to remove the DATABASE_URL from the local .env.server and close the tunnel. If you're still experiencing issues, it might be helpful to check out the related conversation on Discord (https://discord.com/channels/686873244791210014/1168303085442052216/1168303085442052216) for additional directions or things to consider. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @CamBlackwood, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
CamBlackwood
CamBlackwoodOPβ€’5mo ago
the database connection works for sure it's only when I try and useAuth that it's broken looks like pgboss is the issue πŸ€”
[ Server!] errno: -61,
[ Server!] code: 'ECONNREFUSED',
[ Server!] syscall: 'connect',
[ Server!] address: '::1',
[ Server!] port: 5432
[ Server!] }
[ Server ] Server listening on port 3001
[ Server!] node:internal/process/promises:288
[ Server!] triggerUncaughtException(err, true /* fromPromise */);
[ Server!] ^
[ Server!]
[ Server!] [UnhandledPromiseRejection: 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(). The promise rejected with the reason "#<PgBoss>".] {
[ Server!] code: 'ERR_UNHANDLED_REJECTION'
[ Server!] }
[ Server!]
[ Server!] errno: -61,
[ Server!] code: 'ECONNREFUSED',
[ Server!] syscall: 'connect',
[ Server!] address: '::1',
[ Server!] port: 5432
[ Server!] }
[ Server ] Server listening on port 3001
[ Server!] node:internal/process/promises:288
[ Server!] triggerUncaughtException(err, true /* fromPromise */);
[ Server!] ^
[ Server!]
[ Server!] [UnhandledPromiseRejection: 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(). The promise rejected with the reason "#<PgBoss>".] {
[ Server!] code: 'ERR_UNHANDLED_REJECTION'
[ Server!] }
[ Server!]
miho
mihoβ€’5mo ago
Have you maybe tried replacing localhost with 127.0.0.1 or 0.0.0.0 as your DB host?
CamBlackwood
CamBlackwoodOPβ€’5mo ago
That fixed it, thanks πŸ™‚ hmm, I deployed and am getting it on my production environment as well now (can't see the logs directly, but can see a network error in the auth requests in the network tab). I set up a wasp_server_url already and it appears correct
miho
mihoβ€’5mo ago
What's your database setup? Are you using Fly or something else?
CamBlackwood
CamBlackwoodOPβ€’5mo ago
Yeah, all deployed on fly in the standard wasp way
miho
mihoβ€’5mo ago
Could you maybe share your project via a public Github repo or DM me with the zip? I'm not sure what how to debug next πŸ˜„
CamBlackwood
CamBlackwoodOPβ€’5mo ago
Yeah, I'll DM you now πŸ™‚
miho
mihoβ€’5mo ago
This is probably related to https://github.com/wasp-lang/wasp/issues/1621 (localhost vs. 127.0.0.1 change hints at it)
GitHub
Connection to the database via IPv6 fails Β· Issue #1621 Β· wasp-lang...
Some users reported failures with pg-boss's connection to the database. On a closer look, it seems that it's a general database connection issue due to using IPv6 to connect. Check this out...
Want results from more Discord servers?
Add your server