W
Wasp-lang•8mo ago
terrence

fly.io deployment error

I tried to deploy to fly.io, and I set DATABASE_URL, and I tested it can connect successfully with dbms, it still got error saying env not found, how to solve it? Thank you. @miho @martinsos
8 Replies
kapa.ai
kapa.ai•8mo ago
Hi @terrence. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error you're encountering seems to be related to the DATABASE_URL environment variable not being found during the build process. This is a known issue with Wasp and Prisma, as discussed in this Github issue (https://github.com/wasp-lang/wasp/issues/1321). However, as long as you've set the environment variables correctly on Fly, this error should not prevent you from deploying your application. Here's how you can set environment variables on Fly: 1. Navigate to your project directory and run the following commands, replacing <random_string_at_least_32_characters_long>, <url_of_where_client_will_be_deployed>, and <url_of_where_server_will_be_deployed> with your actual values:
flyctl secrets set PORT=8080
flyctl secrets set JWT_SECRET=<random_string_at_least_32_characters_long>
flyctl secrets set WASP_WEB_CLIENT_URL=<url_of_where_client_will_be_deployed>
flyctl secrets set WASP_SERVER_URL=<url_of_where_server_will_be_deployed>
flyctl secrets set PORT=8080
flyctl secrets set JWT_SECRET=<random_string_at_least_32_characters_long>
flyctl secrets set WASP_WEB_CLIENT_URL=<url_of_where_client_will_be_deployed>
flyctl secrets set WASP_SERVER_URL=<url_of_where_server_will_be_deployed>
You can find more details in the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app). If the error persists, a workaround suggested by a community member in this Discord thread (https://discord.com/channels/686873244791210014/1196865084304150639) is to run the deploy/build command inline with your local DB environment variable found in .wasp/out/server/.env. The command would look something like this:
DATABASE_URL="<your_database_url>" wasp deploy fly launch <app_name> den
DATABASE_URL="<your_database_url>" wasp deploy fly launch <app_name> den
Remember to replace <your_database_url> and <app_name> with your actual database URL and application name. Please note that this is a workaround and might not be the best practice. Always ensure to handle your environment variables securely. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @terrence, 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?
terrence
terrenceOP•8mo ago
since I use default port 3001, should I change it to flyctl secrets set PORT=3001? @kapa.ai
kapa.ai
kapa.ai•8mo ago
Let me check the knowledge base for you. One moment! :books:
MEE6
MEE6•8mo ago
Wohooo @terrence, you just became a Waspeteer level 3!
kapa.ai
kapa.ai•8mo ago
---------------------- Yes, you can set the PORT environment variable to 3001 if that's the port your server is listening on. The flyctl secrets set PORT=3001 command will set the PORT environment variable to 3001 for your Fly.io application. Here's how you can do it:
flyctl secrets set PORT=3001
flyctl secrets set PORT=3001
However, please note that the PORT environment variable is used to specify the HTTP port number where the server listens for requests. If you don't set it, the default value is 3001 as mentioned in the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables). Also, be aware that there are discussions in the Wasp community about dynamically assigning ports during local development to avoid conflicts, as seen in these Github issues (https://github.com/wasp-lang/wasp/issues/617) and Github issues (https://github.com/wasp-lang/wasp/issues/730). So, if you're running into issues with port 3001 being occupied, you might want to consider using a different port. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @terrence, 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?
Filip
Filip•8mo ago
Hi @terrence, Did you manage to get this working?
terrence
terrenceOP•8mo ago
yea, it weirdly working somehow, and I dont know how did it fixed...
Filip
Filip•8mo ago
Haha, happens sometimes! 😄 Glad you got it working
Want results from more Discord servers?
Add your server