port 7071 is unavailable. Close the process using that port, or specify another port using --port [-p]
Asked Answered
L

13

24

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?

Lower answered 18/6, 2019 at 11:44 Comment(0)
L
0

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

Lower answered 18/6, 2019 at 13:39 Comment(0)
H
18

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

Huckaback answered 18/2, 2020 at 16:32 Comment(2)
This fixed my issue. FYI as of 2/1/2022 using latest template from VS: under Debug : General - click 'Open debug launch profiles UI' Under that it was called 'Command line arguments'Shu
This along with the comment fixed my issue.Premaxilla
E
18

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

Everglades answered 11/3, 2021 at 13:24 Comment(0)
P
17

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

Per answered 9/9, 2021 at 20:23 Comment(0)
N
9

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):

  1. 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)
  1. 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
  1. next, issue kill on the two process IDs, like so:

    kill -9 14517 14832

that should do it!

Neritic answered 13/2, 2022 at 17:51 Comment(0)
S
4

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.

Sewell answered 20/12, 2019 at 1:6 Comment(0)
A
1

navigate to the project folder and run the below command on terminal

func host start --port 7072
Amalburga answered 14/3, 2023 at 14:47 Comment(0)
L
0

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

Lower answered 18/6, 2019 at 13:39 Comment(0)
N
0

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

Narcoma answered 13/12, 2019 at 6:40 Comment(0)
S
0

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

Simms answered 25/2, 2021 at 16:59 Comment(1)
Because you free ports when you restart your PCEverglades
T
0

To add toi @zolty13 answer

Sometimes it doesn't completely shut down, when you try starting it up again, there's the old process still running, which is why you can't run on that very port, of course, you could easily change the port using the methods provided in the other reply, this isn't efficient as you'd need to update all files using the func project.

@zolty13 provided a solution for windows, however, if you are running on a MacOS, to solve the problem, open spotlight CMD+SPACE -> search and run Activity Monitor -> find your Azure function process and simply kill it. It should help without restarting your PC or changing the port.

It is how it looks on my Mac(Ventura): Activity Monitor Fun Display

Truss answered 3/11, 2022 at 12:57 Comment(0)
U
0

Try another port. For instance: func host start --verbose --port 11000

Ullman answered 31/1, 2023 at 6:9 Comment(1)
Note that he already tried that.Harrier
P
0

I just restarted my computer, and it works ^^

Pansir answered 27/11, 2023 at 8:28 Comment(0)
B
0

On Windows you can just check what app is using this port locally. Go to task manager windows + r and write resmon

run window

Then go to the network tab and TCP connections section. Then sort by local Port and search for the port you are interested in (7071 in your case)

resmon network -> tcp connections section

In my case, the issue was, that for some weird reasons, Spotify took 7071 port. So you have to check who is using it and if possible close the app (or change the port to something else as other answers suggested)

Bradney answered 27/6 at 9:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.