CompVis / stable-diffusion

A latent text-to-image diffusion model
https://ommer-lab.com/research/latent-diffusion-models/
Other
68.27k stars 10.16k forks source link

OSError: All ports from 7860 to 7959 are in use. Please close a port #424

Open fatdennis opened 2 years ago

fatdennis commented 2 years ago

How to close a port? cannot use SD automatic 1111 after the git pull yesterday (24/10/2022)

Sinphaltimus commented 1 year ago

I'm having this issue one a clean install today (11/23/22) - Those ports aren't open or blocked as far as I can tell.

Traceback (most recent call last): File "D:\StableDiffusionGUI\Data\stable-diffusion-webui\launch.py", line 251, in start() File "D:\StableDiffusionGUI\Data\stable-diffusion-webui\launch.py", line 246, in start webui.webui() File "D:\StableDiffusionGUI\Data\stable-diffusion-webui\webui.py", line 155, in webui app, local_url, share_url = demo.launch( File "D:\StableDiffusionGUI\Data\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1298, in launch server_name, server_port, local_url, app, server = networking.start_server( File "D:\StableDiffusionGUI\Data\stable-diffusion-webui\venv\lib\site-packages\gradio\networking.py", line 114, in start_server port = get_first_available_port( File "D:\StableDiffusionGUI\Data\stable-diffusion-webui\venv\lib\site-packages\gradio\networking.py", line 65, in get_first_available_port raise OSError( OSError: All ports from 7860 to 7959 are in use. Please close a port. Press any key to continue . . .

SlayTheVirus commented 1 year ago

I am also experiencing this issue. The issue initially appeared about a week ago, I was able to load the web-UI normally a few days ago but then this issue came back today. I'm not really sure what's going on.

Traceback (most recent call last): File "C:\Users\Slay\sd-webui-new\launch.py", line 295, in start() File "C:\Users\Slay\sd-webui-new\launch.py", line 290, in start webui.webui() File "C:\Users\Slay\sd-webui-new\webui.py", line 140, in webui app, local_url, share_url = shared.demo.launch( File "C:\Users\Slay\sd-webui-new\venv\lib\site-packages\gradio\blocks.py", line 1298, in launch server_name, server_port, local_url, app, server = networking.start_server( File "C:\Users\Slay\sd-webui-new\venv\lib\site-packages\gradio\networking.py", line 114, in start_server port = get_first_available_port( File "C:\Users\Slay\sd-webui-new\venv\lib\site-packages\gradio\networking.py", line 65, in get_first_available_port raise OSError( OSError: All ports from 7860 to 7959 are in use. Please close a port.

bybpow commented 1 year ago

P.S.: Restarting worked for me...

Same here, any solution so far? Ports don't seem to be opened.

Vereinzelte commented 1 year ago

I wrote --port 44444 after Launching Web UI with arguments and it finally worked.

johnnybpena1989 commented 1 year ago

This seems to be a daily thing for me as well. The only solution I have found is doing a full restart of my pc (sometimes more than once). And when my pc restarts, its a grab a cup of coffee kinda wait lol. I know those ports are available because i run a port scan to ensure. I've also changed toe --port flag but that only worked for me once and is only a temporary solution. PC restarts it is! lol

Munoy commented 1 year ago

Here's the solution I found and would like to share.

This works on Windows 10, but should work on other Windows environments as well.

Open Command Prompt and enter the following command:

netstat

This command finds all the processes in use.

Check for the port between 7860 and 7959 with a local address.

For example, if you found that port 7939 is in use, enter the following command:

netstat -ano | findstr :7939

This command finds all the processes currently using port 7939.

Find the value in the "PID" column on the far right of the output after running the command. This is the unique ID of the process using the port.

Enter the following command to terminate the process with the corresponding PID:

taskkill /F /PID [PID] /T

Replace [PID] with the PID value found in the previous step. /F means to force termination. /PID [PID] receives the PID of the process to be terminated. /T means to terminate all processes associated with the target process.

If you have completed these steps, the web-UI should be running again.

Agenlone1y2016 commented 1 year ago

I wrote --port 44444 after Launching Web UI with arguments and it finally worked.

how to?

johnnybpena1989 commented 1 year ago

Here's the solution I found and would like to share.

This works on Windows 10, but should work on other Windows environments as well.

Open Command Prompt and enter the following command:

netstat

This command finds all the processes in use.

Check for the port between 7860 and 7959 with a local address.

For example, if you found that port 7939 is in use, enter the following command:

netstat -ano | findstr :7939

This command finds all the processes currently using port 7939.

Find the value in the "PID" column on the far right of the output after running the command. This is the unique ID of the process using the port.

Enter the following command to terminate the process with the corresponding PID:

taskkill /F /PID [PID] /T

Replace [PID] with the PID value found in the previous step. /F means to force termination. /PID [PID] receives the PID of the process to be terminated. /T means to terminate all processes associated with the target process.

If you have completed these steps, the web-UI should be running again.

Holit commented 1 year ago

Here's the solution I found and would like to share. This works on Windows 10, but should work on other Windows environments as well. Open Command Prompt and enter the following command:

netstat

This command finds all the processes in use. Check for the port between 7860 and 7959 with a local address. For example, if you found that port 7939 is in use, enter the following command:

netstat -ano | findstr :7939

This command finds all the processes currently using port 7939. Find the value in the "PID" column on the far right of the output after running the command. This is the unique ID of the process using the port. Enter the following command to terminate the process with the corresponding PID:

taskkill /F /PID [PID] /T

Replace [PID] with the PID value found in the previous step. /F means to force termination. /PID [PID] receives the PID of the process to be terminated. /T means to terminate all processes associated with the target process. If you have completed these steps, the web-UI should be running again.

68747470733a2f2f692e696d6775722e636f6d2f33576a426e4e312e676966

same, there's no ports in use shown in netstat.

zhzLuke96 commented 1 year ago

I know this is a old issue, but it seems no one has found a solution yet. I have found a solution that good work for me, so I want to share it here:

Firstly, this is not a webui or gradio issue, it's a Windows issue.

If you check the NAT tcp port exclusion range using netsh interface ipv4 show excludedportrange protocol=tcp, you will find 7860 falls within some range... (I guess some cracking software takes advantage of Windows' port permission restrictions to achieve cracking, but fails to properly clean up the port permissions after finishing, leading to this issue).

So naturally, it's simple to just remove these restrictions, like this:

net stop winnat
netsh interface ipv4 show excludedportrange protocol=tcp 
net start winnat
netsh interface ipv4 show excludedportrange protocol=tcp

and you can one single line cmd to restart it:

net stop winnat & net start winnat

Now the port should be free to use again.

TeaRexcellence commented 10 months ago

If you check the NAT tcp port exclusion range using netsh interface ipv4 show excludedportrange protocol=tcp, you will find 7860 falls within some range... (I guess some cracking software takes advantage of Windows' port permission restrictions to achieve cracking, but fails to properly clean up the port permissions after finishing, leading to this issue).

So naturally, it's simple to just remove these restrictions, like this:

net stop winnat
netsh interface ipv4 show excludedportrange protocol=tcp 
net start winnat
netsh interface ipv4 show excludedportrange protocol=tcp

Now the port should be free to use again.

This worked flawlessly for me and free'd up the ports. Cheers man! (To people who dont know, open the command prompt or windows power shell and just copy the above text as one command and paste/enter it into the terminal. Done.)

As for your suggested cause. I have never used cracked software. Can you elaborate on that? Possibly you meant something else. I am curious of the cause as this was a new pc build with a legit copy of windows 11 pro.

Thnx!

-edit on reboot i had to apply it again.