W
Wasp-langβ€’17mo ago
dsifry

Using Wasp with AWS RDS Postgresql?

Hi! I'm pretty new to wasp, and I've been playing with the saas-template, and got it running on localhost on my Mac using the default install. I'm used to using AWS for production deploys, and so I tried deploying wasp onto a server that connects to an AWS RDS instance running postgresql directly, but it appears that the wasp instance isn't reading from the .env-server file to load the DATABASE_URL even though I have uncommented it and filled it with the proper postgres:// url to connect to my db server. Any ideas on how to troubleshoot this? This is the output of wasp db migrate-dev: $ wasp db migrate-dev 🐝 --- Compiling wasp project... -------------------------------------------------- 🐝 --- Setting up database... ----------------------------------------------------- [Db!] Error: P1001 [Db!]
[Db!] Can't reach database server at localhost:5432 [Db!]
[Db!] Please make sure your database server is running at localhost:5432. [Db!]
βœ… --- Database successfully set up. ---------------------------------------------- βœ… --- Your wasp project has successfully compiled. ------------------------------- ❌ --- [Error] Can not connect to database: --------------------------------------- The database needs to be running in order to execute this command. You can easily start a managed dev database with wasp start db.
12 Replies
Vinny (@Wasp)
Vinny (@Wasp)β€’17mo ago
Hey. You need to get the DATABASE_URL from wherever your database is hosted. Then add it to the configuration where your server is hosted. the .env.server file is only for local development Where are you hosting your server?
dsifry
dsifryOPβ€’17mo ago
I'm hosting it on an AWS RDS box running Postgresql, so I'm not using a provider like Heroku or Fly.io. The DATABASE_URL I have specified runs fine and connects to the correct database machine when I run it from the command line on my web server using psql . It appears, however, that when I'm trying to run the wasp app on my web server, it isn't using the .env-server file. Is that correct? Sorry for the newbie prisma questions!
Vinny (@Wasp)
Vinny (@Wasp)β€’17mo ago
yeah so somewhere in the server configuration on AWS you need to configure the DATABASE_URL to point to your hosted DB's connection URL. The .env.server file is not being used anymore at this point (it's just for local development)
Vinny (@Wasp)
Vinny (@Wasp)β€’17mo ago
we have a section about manually deploying in our docs/guides: https://wasp-lang.dev/docs/deploying#manual-deployment
Deploying | Wasp
Wasp is in beta, so keep in mind there might be some kinks / bugs, and possibly a bit bigger changes in the future.
Vinny (@Wasp)
Vinny (@Wasp)β€’17mo ago
@miho do you have any experience deploying to AWS RDS?
miho
mihoβ€’17mo ago
I can't say that I do, but you said the correct thing. You should set up the DATABASE_URL env variable on your server to point to your RDS database.
dsifry
dsifryOPβ€’17mo ago
How do I do that? I assume its somewhere in .wasp/out ?
MEE6
MEE6β€’17mo ago
Wohooo @dsifry, you just became a Waspeteer level 1!
Vinny (@Wasp)
Vinny (@Wasp)β€’17mo ago
no it will be in your AWS RDS configuration, either in the settings on the AWS dashboard or via their CLI
dsifry
dsifryOPβ€’17mo ago
if that's the case, I have a working DATABASE_URL - but it appears that when I run wasp db migrate-dev from the web server, it fails. Am I doing the database migration from the wrong machine? I thought I would do it from the web server where the node.js server is running, as it then connects to the database via the URL in DATABASE_URL. Am I misreading how it works?
miho
mihoβ€’17mo ago
Where are you deploying your Node.js app? Is it EC2 or something else?
martinsos
martinsosβ€’16mo ago
@dsifry the docker image that Wasp produces for you should alread run db migrate-dev for you when starting the wasp server! Maybe it is best if you provide us with a bit more info: where exactly do you deploy the server (EC2?), what do you deploy (did you use Docker image that Wasp generates, or did you do something else?), ... . We have instructions in docs for manual deployment (https://wasp-lang.dev/docs/advanced/deployment/manually), so anything you did different than that is important to emphasize, so we know what is the situation. I will close the issues for now as it has been some time since the last response, but feel free to continue writing here and we will respond!
Want results from more Discord servers?
Add your server