Database not connecting on fly.io

Latest version of wasp (updated this morning, but persisting through previous version) Running on WSL Image attached of error (network error) being there, and the console log on browser. This wasn't a problem on fresh deploy (everything appeared to work, I was in the middle of setting up email connectivity) Everything works on local host perfectly fine. But, now that I've ran wasp deploy fly deploy a few times this appeared. When I redeploy I get this Db error
[ Db !] Error: P1012
[ Db !]
[ Db !] error: Environment variable not found: DATABASE_URL.
[ Db !] --> schema.prisma:4
[ Db !] |
[ Db !] 3 | provider = "postgresql"
[ Db !] 4 | url = env("DATABASE_URL")
[ Db !] |
[ Db !]
[ Db !]
[ Db !] Error: P1012
[ Db !]
[ Db !] error: Environment variable not found: DATABASE_URL.
[ Db !] --> schema.prisma:4
[ Db !] |
[ Db !] 3 | provider = "postgresql"
[ Db !] 4 | url = env("DATABASE_URL")
[ Db !] |
[ Db !]
[ Db !]
Any help would be appreciated, I ran into this last night, and assumed I installed incorrectly and then completely deleted and redeployed to Fly, which I thought resolved the problem, but it appears to have came again. From it working to it not working - is change my email and run wasp deploy fly deploy. Changing email back makes no difference.
No description
No description
18 Replies
kapa.ai
kapa.ai7mo ago
Hi @Joshua. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error message you're seeing is related to the DATABASE_URL environment variable not being found. This variable is required for your Wasp app to connect to the PostgreSQL database. Here are some steps you can take to resolve this issue: 1. Set up the DATABASE_URL on Fly.io: When you set up your Fly.io app, you should have been asked if you'd like to set up a PostgreSQL database. If you said yes, Fly.io should have set a DATABASE_URL for you. If this didn't happen, or if you're unsure, you can manually set this environment variable. You can do this by running the following command in your terminal:
flyctl secrets set DATABASE_URL=<your_database_url>

flyctl secrets set DATABASE_URL=<your_database_url>

Replace <your_database_url> with the actual URL of your PostgreSQL database. The URL should look something like this: postgresql://mydbuser:mypass@localhost:5432/nameofmydb. You can check if you've added your secrets correctly by running flyctl secrets list in the terminal. Note that you will see hashed versions of your secrets to protect your sensitive data. source (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app) 2. Check your Prisma setup: The error message is reported by Prisma, which means it might be related to your Prisma setup. Make sure your schema.prisma file is correctly set up and that the DATABASE_URL is correctly referenced. source (https://github.com/wasp-lang/wasp/issues/1321) 3. Ignore the error if it doesn't prevent deployment: According to a Wasp community member, if the error doesn't prevent you from deploying, you can safely ignore it. This is a Prisma error that occurs while building the app for deployment, but it shouldn't matter if you set the environment variables on Fly properly. source (https://discord.com/channels/686873244791210014/1196865084304150639) If you're still having trouble, please provide more information or consider opening an issue on the Wasp Github page (https://github.com/wasp-lang/wasp/issues). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Joshua, 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?
Joshua
Joshua7mo ago
secrets are there apparently
No description
miho
miho7mo ago
What do you see in the Fly sever logs?
Joshua
Joshua7mo ago
hmm
No description
Joshua
Joshua7mo ago
That's when I press login or create email This is after I just updated & redpoloyed with my stored secret
Joshua
Joshua7mo ago
Still same cors error & network error
No description
miho
miho7mo ago
Are you using a custom domain for the frontend?
Joshua
Joshua7mo ago
I set it up to be one, yes
MEE6
MEE67mo ago
Wohooo @Joshua, you just became a Waspeteer level 2!
Joshua
Joshua7mo ago
I completed steps 1 (validated with retrying and receiving back: Hostname already exists on app) & 2 (set A & AAAA on vercel) from https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app, and for step 3 When I type: wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=https://mycoolapp.com It stops at checking DNS (image below), this happened the first time I did this, and second time. and then never actually deploys to gulearn.com The connection error I am receiving is on https://gulearn-client.fly.dev/ Which is still active.
No description
miho
miho7mo ago
Oh yes! Once you set the domain name and the env variable, you can no longer use the .fly.dev subdomain 🙂
martinsos
martinsos7mo ago
Ha ok I also wasn't sure about that? Do we mention it in docs, in the 'custom domain" part? If not, should we?
Joshua
Joshua7mo ago
My follow up question, is how long does a custom domain take to actually start working after this from your experience? Should it be instant? Should it be 24 -48 hrs? Or am I doing something wrong? Been poking around docs and can't find anywhere. (got that number from google/gpt searching) I think my impatience is just getting me, so I'm just trying to trial things on live server (but obviously not working that way) and the .fly.dev is still up [though network error/disconnected from backend] with 404 on my custom domain
martinsos
martinsos7mo ago
So it can take longer time, I think officialy you will find sometihng like 24-48 hours, but in practice, it takes more like 5 to 15 minutes (although it can be longer). So I would say likely it is a couple to 15 minutes, but it can be longer, which is tricky, because you can't know :).
Joshua
Joshua7mo ago
Right on, I'll go ahead and just be patient then at 48 hours or so, try and do other stuff and just develop on local in the meantime. 🙂 For note incase anyone goes through this and is reading through convos: Vercel was where my domain was, and it just didn't switch with A and AAAA set (48hrs waited) I bought a GoDaddy domain, and as Martin said above, it was up in around 10 minutes following the same set up instructions. My ideal domain is on vercel, but I'll have to wait 60 days after purchase for it to move 🤷‍♂️
miho
miho7mo ago
Oh my, can you update the nameservers so you can manage the DNS somewhere else? You don't have to move the domain to another registar to do this. This is what I usually do: - buy the domain somewhere (I use Porkbun) - set the nameservers to Cloudflare - I can then manage DNS records in Cloudflare and get the benefits of their CDN and DDOS protection
Joshua
Joshua7mo ago
duly noted, added to my readme to loop back to once I get more features implemented! Thanks for the suggestion! Not sure if Vercel lets me, but will dig in later!
martinsos
martinsos7mo ago
Oh wow waiting for 60 days? Why is that, that is in their rules? Interesting. I am not a dns/domain expert, so maybe there is some good reason for it, but sounds like a bit much. Good to know that you managed to solve it though, at least for now!
Want results from more Discord servers?
Add your server