Restart wasp db

I terminated my database, and I am trying to get it running again. How do I do this?
12 Replies
kapa.ai
kapa.ai7mo ago
Hi @George. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To restart your Wasp database, you can use the wasp start db command. This command will start a default PostgreSQL dev database for your Wasp app. Your app will automatically connect to it, so you just need to keep wasp start db running in the background. Here are the steps: 1. Open your terminal. 2. Navigate to your Wasp project directory. 3. Run the command wasp start db. Please ensure that: - You have Docker installed and in PATH. You can check if Docker is installed by running docker -v in your terminal. If you don't have Docker installed, you can download it from here (https://www.docker.com/get-started/). - The port 5432 isn't taken by another process. You can check this by running lsof -i :5432 in your terminal. If there's a process running on this port, you might need to stop it before running the wasp start db command. If you're still having trouble, it might be helpful to restart your machine as some users have reported this resolving similar issues[^1^][^2^]. ^1^]: [Source (https://discord.com/channels/686873244791210014/1179895919471247490) ^2^]: [Source (https://discord.com/channels/686873244791210014/1223569423177089093) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @George, 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?
George
George7mo ago
When I press play on docker
No description
George
George7mo ago
This is preventing me from starting the app (after running wasp start)
No description
miho
miho7mo ago
Did you try running the DB using the command the bot suggested? 😊 If you start the DB in any other way, you need to provide the correct env var. @kapa.ai
kapa.ai
kapa.ai7mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Yes, to connect your Wasp app to a database, you can use the wasp start db command which starts a default PostgreSQL dev database. Your app will automatically connect to this database as long as wasp start db is running in the background. However, if you want to connect to an existing database or spin up your own dev database, you need to provide the DATABASE_URL environment variable. This variable should contain the connection string to your database. You can set this variable in the .env.server file in the root directory of your Wasp project. If the file doesn't exist, you can create it. Here's how you can set the DATABASE_URL inline when running wasp:
DATABASE_URL=<my-db-url> wasp ...
DATABASE_URL=<my-db-url> wasp ...
This is useful for running a specific wasp command on a specific database. For example:
DATABASE_URL=<production-db-url> wasp db seed myProductionSeed
DATABASE_URL=<production-db-url> wasp db seed myProductionSeed
This command seeds the data for a fresh staging or production database[^1^]. ^1^]: [Source (https://wasp-lang.dev/docs/data-model/backends#connecting-to-a-database) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @miho, 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?
George
George7mo ago
Yes, but I wasn’t sure if it was only for setting it up for first time I will send screenshot in soon of what happens, I am on bus right now 🤦‍♂️ it worked this time, my bad!
MEE6
MEE67mo ago
Wohooo @George, you just became a Waspeteer level 1!
George
George7mo ago
Thank you
miho
miho7mo ago
Thank you for using Wasp 🤗
martinsos
martinsos7mo ago
@George was there anything you find confusing that you think we can improve, to help others avoid having the same mistake?
George
George7mo ago
Well when I stopped just stopped the server(s) by killing the terminal. When I tried to run it again, it was saying how a port was already in use. I can't remember which, but it started with 5. Maybe something in the documentation clarifying how to properly stop the server
martinsos
martinsos7mo ago
Ah yes, that is port 5432, one used for the database. That is actually an ok way to stop it, for some reason the db stays occupied, we are still not sure in which cases, it happens only sometimes. Are you on Mac?
Want results from more Discord servers?
Add your server