Port is already in use

I was working on a Node.js application. During development, it was running on the local server. Whenever I made changes to the application and tried to run it again, it would not run on the specified port number. Each time, I had to change the port number, even after a minor modification. Can anyone explain why this is happening?