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
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:
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:
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?since I use default port 3001, should I change it to flyctl secrets set PORT=3001? @kapa.ai
Let me check the knowledge base for you. One moment! :books:
Wohooo @terrence, you just became a Waspeteer level 3!
----------------------
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:
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?Hi @terrence, Did you manage to get this working?
yea, it weirdly working somehow, and I dont know how did it fixed...
Haha, happens sometimes! 😄
Glad you got it working