Cannot Access dB once Deployed...

Hi, all! I'm running into an error with any Wasp apps that use a dB after deploy. During development on localhost, the wasp client and server work just fine and the server connects to the dB (running on Supabase) just fine. The app works just fine. BUT THEN: I deploy the app and run into errors with the dB. The wasp server and client work with any page / function that does not call out to the dB. But when accessing the dB while deployed, I just get errors. I have my own servers I rent from Hetzner and am using Coolify to deploy. Once again, the server and client work fine and any page that does not use the dB loads up just as one would expect. Trying to log in gives me a "405" error when accessing the dB. Thinking the problem might be Coolify, I decided to deploy on Fly.io. This time, I get a "network error" when accessing the dB instead of a "405" error. THEN, I tried using the Postgre dB that Fly.io offers -- STILL get a "network error" when the app accesses the dB. My DATABASE_URL is properly set both on my Coolify instance and when I tried it on Fly.io. I have no idea what is going on. When running locally the app calls out to the Supabase db just fine, with no errors. I have spent several hours trying to debug this problem and all I have done is waste time and energy. Currently, I am only replicating the "Todo" app from the Tutorial -- so this is not some big and complicated App. I really want to use Wasp instead of having to learn Next.js. What am I doing wrong? Please, help!
9 Replies
kapa.ai
kapa.ai4mo ago
Hi @ChaosOptimized. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry to hear about the issues you're experiencing. Let's try to troubleshoot this step by step. 1. Check your Wasp version: Make sure you're running at least Wasp 0.12.4. There was a bug fix related to imports that might be relevant. You can check your Wasp version by running wasp version. If you need to upgrade, you can do so by running curl -sSL <https://get.wasp-lang.dev/installer.sh> | sh -s -- -v 0.12.4 source (https://discord.com/channels/686873244791210014/1223671727943319584). 2. Check your DATABASE_URL: Ensure that your DATABASE_URL environment variable is correctly set in your deployment environment. This is crucial for your application to connect to the database. You can set environment variables on Fly.io as described in the Wasp documentation (https://wasp-lang.dev/docs/project/env-vars). 3. Inspect the deployed code: You can inspect the exact code that gets deployed by looking into the .wasp/build folder. This might give you some insights into what's going wrong source (https://discord.com/channels/686873244791210014/1223671727943319584). 4. Check the database connection: If you're using Fly.io's Postgres database, you can open up a tunnel to connect to your production database with fly proxy 5432 -a <db-name>. Then, you can execute wasp db studio to interact with your database source (https://discord.com/channels/686873244791210014/1220423321422663820). 5. Check for error messages: Look for any error messages in your server logs or console output. These might give you a clue about what's going wrong. If none of these steps help, it would be beneficial to share the exact error messages you're seeing, as well as any relevant code or configuration details. This will make it easier for the community to help you troubleshoot the issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ChaosOptimized, 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?
miho
miho4mo ago
Hey, let’s try to figure this out together. Nice to see someone use Coolify, I quite like it as well! I’ve used Supabase + Wasp successfully in this project: https://github.com/wasp-lang/lazy-card-generator and I’ve just set the DATABASE_URL to the Supabase URL from the Dashboard (I believe you did the same since it works locally for you). 1. Did you set the DATABASE_URL to the same value as in development? Maybe you added extra quotes you don’t need? 2. The app I linked above is deployed to Fly and uses Supabase. Can you share your postgres:// connection string (hide the pw obviously)?
GitHub
GitHub - wasp-lang/lazy-card-generator: Demonstration of Wasp and S...
Demonstration of Wasp and Supabase working together, using Llama 3 and SDXL to generate greeting cards! - wasp-lang/lazy-card-generator
ChaosOptimized
ChaosOptimized4mo ago
Just checked, I have my DATABASE_URL set to the same value both in dev and on Coolify/Fly.io. And my postgre connection string is: postgres://postgres.(rest-of-user-string):(password)@aws-0-us-east-1.pooler.supabase.com:5432/postgres I'm off to sleep land but tomorrow after work I will try and get your lazy-card-generator working on my Coolify @miho . Hopefully, I can get that working and see what I am doing wrong with my own deploy/app!
miho
miho4mo ago
I think that Supabase offer you two different connection strings, but I see you are using the same one as I did:
DATABASE_URL=postgres://postgres.<project-id>:<password>@aws-0-eu-central-1.pooler.supabase.com:5432/postgres
DATABASE_URL=postgres://postgres.<project-id>:<password>@aws-0-eu-central-1.pooler.supabase.com:5432/postgres
Let me know when you start debugging the app again, maybe I can try using your connection string or smth to see if it would for my setup 😄 Could you also share the server log from the Fly dashboard as well?
ChaosOptimized
ChaosOptimized4mo ago
@miho I got it working! I misread one of the build instructions and I had this in my build script: REACT_APP_API_URL=$WASP_WEB_CLIENT_URL When it should have been: REACT_APP_API_URL=$WASP_SERVER_URL
MEE6
MEE64mo ago
Wohooo @ChaosOptimized, you just became a Waspeteer level 1!
ChaosOptimized
ChaosOptimized4mo ago
Now I have the Wasp client, server AND postgres server all running on Coolify!
miho
miho4mo ago
I'm so glad to hear that! Could you maybe write about how you set it up with Coolify? Like a mini tutorial or smth 😊
martinsos
martinsos4mo ago
yeah, the easiest is just opening an issue on our github with title like "How to setup wasp on coolify", that will help us write the docs potentially! next step would be actually writing the docs page but that i a bit more involved.
Want results from more Discord servers?
Add your server