How did I do?*

Find what ports are being used by what application

If you're trying to debug a web application locally you may have occasionally found that the port you've specified the app to run on is already in use by another service.

You may want to check which app is using the port, in case it's an error, or try to find a free port in order to switch your app's launch settings over to using a free one.

If you're using Windows, you can check a specific port's usage in PowerShell:

Get-Process -Id (Get-NetTCPConnection -LocalPort 5173).OwningProcess
Port usage command in PowerShell
Port usage command in PowerShell

Or if you prefer a GUI, you can open the Resource Monitor from the start menu and check the Network tab > Listening Ports (uou may need Administrator privileges to view this monitor).

Resource Monitoring showing port usage
Resource Monitoring showing port usage

You can switch the port an app runs on in a Visual Studio project by amending the launchSettings.json

launchSettings.json file with the port property underlined
launchSettings.json file running on the specified port

Or if you're running an Express.js server, you can specify the port in your index.js, either hard-coded, or more commonly, by referencing an environment variable. The example below uses the environment variable PORT, or 5000 if there's no value set.

const app = express()
const port = process.env.PORT || 5000
app.listen(port, () => console.log(`Server listening on port ${port}`))