Azure Functions: Port XXXX is Unavailable Error While Debugging Locally

Everything had been running fine while you were working locally to debug your newly written (or written a long time ago, doesn’t matter) Azure Function and got interrupted by a stupid error message one like following:

Port 7071 is unavailable. Close the process using that port, or specify another port using –port [-p].

No worries, I’ve got your back ๐Ÿ™‚ This has a very simple reason: Because there is already a function running on background or that function was long gone but the ghost still haunts you. Solution is extremely easy: Open Task Manager and Kill the func.exe (Continue reading this post before you do that)

However!!! There is a big BUT there. What if one of your colleagues are already working on the same machine and executing another function simultaneously. They have the right to do so right? Yes, they have ๐Ÿ™‚

Anyway, while we are debugging we should be able to specify the port on which our local function runs. Solution may vary depending on which version of Azure Functions, which framework and which IDE that you use. (Thank MS for making it so colorful). If you are using Function Runtime 3 and VS 2019+ then that is relatively easy:

Open Project Properties and go to Debug tab. Paste following command arguments:

start --port <Specify your port here>

Note that, if you are using runtime 2, you may have to specify the exact path of the func.dll and provide a command like below:

C:\Users\<Your user name here>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.dll host start --port <Specify your port here> --pause-on-error