How To Prevent From Using Different Port?

Hi there, sometimes, whenever there are new prompts and code were updated, the localhost port will switch to a new one instead of refreshing the current one. Anyway to prevent this? Thanks!