10
votes

I try to run the azure function app (Http Triggerd API) from my local (using VS code). But I'm getting an error "port 7071 is unavailable. Close the process using that port, or specify another port using --port [-p]." I checked the list of ports used using cmd prompt.But 7071 is not in used list. Also tried to run with different port using "func host start --port [p1]", but it throws the same error as above. For all ports it throws the same error. How to resolve this problem?

7

7 Answers

12
votes

Goto Project Properties -> Debug -> Application Argument -> paste this -> host start --pause-on-error --port 5800

you will have new port for your Azure Function: http://localhost:5800/api/Function1

3
votes

If running in development make sure you don't have another azure function sitting in debug mode. I was getting this error until I stopped the other function.

3
votes

Sometimes it might happend that port is in use despite there is no other azure funtion in debug mode.

On Windows10 To solve problem turn on Windows Task Manager ctrl + shift + esc. Find your Azure function proccess and simply kill it. It should help without restarting your PC.

It is how it looks like on my PC: enter image description here

0
votes

Its due to the antivirus. After disabling the antivirus it works fine.

0
votes

On Windows, Adding ports in the Windows firewall rules solved the issue for me.

0
votes

Not sure why this resolved it for me, but I had to restart my machine then all was fine.

0
votes

If you use a vs code update local.settings.json as

ex settings

enter image description here

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
  },
  "ConnectionStrings": {
    "ConnectionString1": "............."

  },
  **"Host": {
    "LocalHttpPort": 5004
  }**
}

then go to http://localhost:5004/api/functionname