change what port wasp is listening on
hey all looking for some help - i am on linux system if relevant (inb4 i use linux)
really simple i think - starting up my wasp app for first time, i cant
because
i think i started my DB on localhost:4000 - any way i can get the wasp app/wasp start/db to listen on port 4000 instead?
i tried checking the env server/ env client files but didnt see anything there, maybe its somewhere else to change where im listening to for the db?
does this make sense yall? ty for help π
8 Replies
Hi @beechain. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, your question makes sense. Currently, Wasp does not provide a built-in way to change the port on which the database is running. The port is hardcoded to 5432 and there is no configuration option to change it. This is a known issue and there are open discussions on GitHub about allowing the user to specify a different port for the managed dev database (source (https://github.com/wasp-lang/wasp/issues/1049)) and for the Wasp development server (source (https://github.com/wasp-lang/wasp/issues/730)).
However, there are some workarounds you can try:
1. Change the
DATABASE_URL
environment variable: You can try setting the DATABASE_URL
environment variable to point to your database running on port 4000. This variable is used to specify the connection string for the database. You would set it to something like postgresql://localhost:4000/mydatabase
. This was suggested in a Discord support thread (https://discord.com/channels/686873244791210014/1179895919471247490).
2. Stop any other process using port 5432: If there is another process (like a local Postgres instance) using port 5432, you could stop that process to free up the port. This was also suggested in the same Discord support thread (https://discord.com/channels/686873244791210014/1179895919471247490).
Please note that these are just workarounds and may not work in all situations. The Wasp team is aware of this limitation and is working on a more flexible solution.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @beechain, 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?Right, so you need a database running.
First way to do that is by running
wasp db start
so wasp will run it for you. leave it running in seprate terminal window and you should be good.
Second way is to run it on your own, but then you need to specify DATABASE_URL in .env.server
. you will also speicfy the port there as part of the URL.
You mentioned you think you ran a database on port 4000. First, it would be great if you were sur eabout that :D. SEcond, if you want to use that database, you should obtain its connection URL that has db name, user name, password, port, and then set that as DATABASE_URL.
Or, just go with wasp db start
.
Check out the docs here for more info: https://wasp-lang.dev/docs/data-model/backendsDatabases | Wasp
Entities, Operations and Automatic CRUD together make a high-level interface for working with your app's data. Still, all that data has to live somewhere, so let's see how Wasp deals with databases.
hey martinsos, i did the wasp db start thing you mentioned - im listening on 5432 now. but i get this when error when i wasp db migrate-dev
any advice around this? or places u can refer me to? something with my ts not being up to date? i have node v18.19, so i dont think the node16 needs to be updated
Wohooo @beechain, you just became a Waspeteer level 1!
pls & ty^
@martinsos or other admin help plz
Yup yup I am here!
Hm, can you show me the rest of theoutput you get before this error message?
Please let me know what
node --version
tells you. I know you wrote 18.19 but just to double check.
Also, try doing waap clean
and then running wasp start
again.
Finally, if that didn't help, try switching to node 20
(e.g using nvm
) and also do wasp clean
and then wasp start
and see if that helps.
If any of these helps, please let me know exactly which step helped, it will help us identify the initial issue!yooooo lfg
ty martinsos π₯
yup cleaned and started again, it took a few tries, but node 20 via nvm helped
Awesome! Sorry that it happens at all, we are looking into that will be doing a refactor that should minimize occurences like this.