W
Waspβ€’2w ago
Mrr

DATABASE_URL not found in fly during deployment

Bug?? wasp deploy fly deploy fails with DATABASE_URL error even though secret exists (v0.15.2) I'm getting a deployment blocker where wasp deploy fly deploy fails with: πŸš€ Your server app does not have a DATABASE_URL secret set. Perhaps you need to create or attach your database? The issue: DATABASE_URL IS set and the app is running fine in production. The bug is that Wasp runs flyctl secrets list -j, receives DATABASE_URL in the response, but still reports it missing. Evidence: # DATABASE_URL exists in Fly secrets $ wasp deploy fly cmd secrets list --context server | grep DATABASE_URL DATABASE_URL 44432e8ef938bde0 # But wasp deploy fails, even though it gets DATABASE_URL back $ wasp deploy fly deploy [... builds successfully ...] $ flyctl secrets list -j [{"name": "DATABASE_URL", "digest": "44432e8ef938bde0"}, ...] πŸš€ Your server app does not have a DATABASE_URL secret set. ❌ Deploy command failed with exit code: 1
4 Replies
kapa.ai
kapa.aiβ€’2w ago
Hi @Mrr. 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 information in the knowledge sources, this is a known issue that has affected some Wasp users during deployment to Fly.io. The error message:
πŸš€ Your server app does not have a DATABASE_URL secret set. Perhaps you need to create or attach your database?
can appear even when the DATABASE_URL secret is present and visible via both Fly and Wasp CLI commands. This has been reported in both GitHub issues and community discussions. Key points from the sources: - The error is sometimes caused by a mismatch or timing issue between when secrets are set and when Wasp checks for them. There have been reports of Prisma or Wasp not detecting the DATABASE_URL even though it is set as a Fly secret, leading to confusing errors during build or deploy steps. This is discussed in issues like #1321 and #1282. - Community members have worked around this by exporting the DATABASE_URL inline with the deploy command, e.g.:
DATABASE_URL="<your_database_url>" wasp deploy fly deploy

DATABASE_URL="<your_database_url>" wasp deploy fly deploy

However, this is considered a workaround and not an ideal solution. The underlying cause seems to be related to how/when environment variables are loaded and checked during the deployment process, especially in the build phase, which may not have access to the secrets set on Fly yet. This is echoed in Discord support threads and GitHub issues, where users note that the error can be ignored if the app runs fine in production, but in your case, it is blocking deployment, which is not expected behavior Discord support thread. What you can try: - Double-check that the secret is set in the correct Fly app context (sometimes secrets are set on the wrong app, e.g., the database app instead of the server app). - Try restarting the deployment process after ensuring the secret is set. - If the error persists, you may use the inline environment variable workaround as a temporary measure:
DATABASE_URL="<your_database_url>" wasp deploy fly deploy

DATABASE_URL="<your_database_url>" wasp deploy fly deploy

- If you continue to encounter this issue, it may be a bug in Wasp's deployment logic. In that case, consider opening or commenting on a GitHub issue with detailed logs and steps to reproduce, as this helps the maintainers track and resolve such problems. Summary:
This is a known issue, and while there are workarounds, the knowledge sources do not provide a definitive fix. The Wasp team is aware of related problems, and improvements to error handling and environment variable detection are ongoing. If your app is running fine in production, the error may be a false negative, but if it blocks deployment, using the inline workaround or reporting the bug with details is recommended. If you need more detailed troubleshooting steps, please provide additional context or logs, or check for updates in the Wasp GitHub issues and deployment docs. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Mrr, 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?
MEE6
MEE6β€’2w ago
Wohooo @genyus, you just became a Waspeteer level 11!
miho
mihoβ€’2w ago
Thank you @genyus for linking, that's the solution πŸ‘

Did you find this page helpful?