Svelte project error port 3000 is already in use

Viewed 50

I'm new to web development, and even newer to Svelte. I opened up a project and everything went fine. When I ran 'npm run dev' it pointed me to localhost 8080 and everything went well--rollup launched and my code was changed live on the browser. Nice. The next day when I opened up vs code and typed 'npm run dev' in the terminal, either nothing happened, or it told me to use port 3000 (which doesn't work) or told me port 3000 is already in used. Anyway, I simply cannot get Rollup to watch anymore. This is all very strange since the only thing I did was shut down VSCode for the evening and then reopen the project the next day; I didn't change anything. I really have no idea what to do except start a new project and never ever close it down until I'm done. What am I doing wrong?

1 Answers

Sometimes when I start a server from a VS Code terminal, then close VS Code without stopping the server, the server is still running and using the port. (Windows 11)

To ensure this doesn't happen, always kill the server process before exiting VS Code. (CTRL-C while focus is inside terminal).

To free the port from a zombie server process, you will either need to kill the process or reboot.

Related