Changing the dev port nuimber

I have several needle projects open at once and want each of them to use a different port number. They are all using the Vite template and I have changed the port number in the vite.config.js to point at port 3001 instead of 3000.

When I click “Start Server” it launches a shell and VITE runs the server reporting the correct port number (3001), but the browser launches with port 3000 which doesn’t work. Changing the browser lurl to port 3001 opens the correct instance.

Is there somewhere i can change the port that’s being launched or is this a bug/feature needed in the tools?

Original Post on Discord

by user 563549194137239552

I looked in the Needle Unity settings to see if the port was settable there. If this is a new feautre, it would make sense for the port setting to be in there.

by user 563549194137239552

Yeah, I think the Unity side is hardcoded right now to open that URL, would make sense to look it up from the vite config

As a workaround, you can also start the server from inside the VS Code workspace, which will give you a link to open it as well

I’d like to learn more about your multi-instance workflow! What are you using it for, what could be better/easier, …

Next version will lookup the port in the vite config and open the correct url

I am just running multiple instances of Unity to work on separate projects that don’t have much to do with each other. Nothing too mysterious.

by user 563549194137239552

Ah but dont they stop each others servers too right now?

(e.g. if you open project 1 and start the server and then open project 2 and click play it would close project 1’s server)

I haven’t tested with multiple needle projects but when I have accidentally been using the default needle port it just fails to start the server, nothing already running stops.

by user 197684733801529344

It just stops running vite / node servers - not just any other apps that might block the port

It doesn’t stop other node servers. That is what I was running.

by user 197684733801529344

Other vite node servers started from Unity?

I’m not sure if it stops them. It probably does, but that is not what I want. I want multiple unity projects open, and i want to run a server on each. I want to compare one server with another.

by user 563549194137239552

I think it does stop the other server but that is one of the reasons i want to run a different unity project on a different port. I don’t want working on one project to stop the other project.

by user 563549194137239552

Understood :slightly_smiling_face: