'port 7071 is unavailable. Close the process using that port, or specify another port using --port [-p]
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?
Solution 1:[1]
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
Solution 2:[2]
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.
Solution 3:[3]
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.
Solution 4:[4]
If you use a vs code update local.settings.json as
ex settings
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
},
"ConnectionStrings": {
"ConnectionString1": "............."
},
**"Host": {
"LocalHttpPort": 5004
}**
}
then go to http://localhost:5004/api/functionname
Solution 5:[5]
On Windows, Adding ports in the Windows firewall rules solved the issue for me.
Solution 6:[6]
Not sure why this resolved it for me, but I had to restart my machine then all was fine.
Solution 7:[7]
This happened to me in linux environment, while trying to run a azure function locally from inside eclipse. turns out that terminating the process from inside the eclipse console DOES NOT kill the process, hence the port being used (7071) is not released till the machine is restarted. Here the detective work needed to figure out if this is the case (linux only):
- Run the following command to find out if the port is indeed occupied
sudo lsof -i -P -n | grep LISTEN
In my case, the output looked like this:
func 11421 s-----v 261u IPv4 105109 0t0 TCP 127.0.0.1:44367 (LISTEN)
func 11421 s-----v 293u IPv4 103143 0t0 TCP *:7071 (LISTEN)
If you see this, it means the process holding 7071 needs to be killed. For doing so, first find the process id for the process that is holding up the ports, like so:
ps -ef | grep func | grep -v grep
This will give you the process id to be killed, the output may look something like this:
s-----v 14517 1 6 12:36 ? 00:00:05 func host start
s-----v 14832 14517 11 12:38 ? 00:00:00 /usr/lib/jvm/jdk-17/bin/java -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -noverify -Djava.net.preferIPv4Stack=true -jar /usr/lib/azure-functions-core-tools-4/workers/java/azure-functions-java-worker.jar --host 127.0.0.1 --port 34867 --workerId 1298e58c-8104-4c98-b440-f617b8f6943d --requestId c01f56cd-a29c-4ba6-b147-f2a15ea7c4d6 --grpcMaxMessageLength 2147483647
next, issue kill on the two process IDs, like so:
kill -9 14517 14832
that should do it!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | KirtiSagar |
| Solution 2 | zolty13 |
| Solution 3 | Jagged |
| Solution 4 | Ivan Barayev |
| Solution 5 | Rama |
| Solution 6 | Nathan Hadley |
| Solution 7 | user2921058 |


