Solution to Windows system port being occupied, reasons why the port is occupied

WBOY
Release: 2024-06-19 03:34:47
Original
1031 people have browsed it

The port is occupied and the operation of the website is affected. Let PHP Editor Banana help you solve your problems! This article will deeply analyze the reasons why the port is occupied and provide a series of effective solutions. Come discover how to easily free up ports and keep your website running smoothly!

When running the software, the port will be occupied. Let’s talk about how to solve it.

Check what software is occupied

1) Use Run to open cmd, directly enter netstat -ano and press Enter. You can see the PID of port 135=1316 and the PID of port 445=4.

Solution to Windows system port being occupied, reasons why the port is occupied

#2) In the task manager, for detailed information, you can find the corresponding process according to the PID.

Solution to Windows system port being occupied, reasons why the port is occupied

#3) Check the PID according to the occupied port, use run to open cmd, enter the following command directly, and press Enter.

Solution to Windows system port being occupied, reasons why the port is occupied

netstat -aon | find "8681" or netstat -aon | grep "8681"

# is to check the occupancy of a single port 8681

netstat -aon | findstr "80" or netstat -aon | findstr :80

# is to view a series of ports containing 80, such as 800, 8080

4) According to the process number Kill the process "taskkill -f -pid 5072" or "taskkill /T /F /PID 5072", or find the corresponding process in the task manager and end the process directly.

The occupied process cannot be found

It indicates that the port is occupied, but the occupied process cannot be found. The reason is that Windows reserves some ports that happen to be in the port sequence reserved by the system.

Use the following command to view

netsh interface ipv4 show excludedportrange protocol=tcp

Solution to Windows system port being occupied, reasons why the port is occupied

If there is nothing in the above picture, it means it is not listed as reserved by the system. The port, if available, will be displayed in a red box.

Possible reasons why Windows reserves these ports:

Blocked by Microsoft due to discovery of virus activity

After installing windows update, the list of reserved ports has changed

Enable Hyper-V feature (install docker, or Linux virtual machine)

Solution:

1. Restart the computer until the required port is no longer among the reserved ports (depending on luck)

2. If the software can change the port, directly change other ports

3. Exclude these reserved ports

netsh int ipv4 add excludedportrange protocol=tcp startport=8888 numberofports =10

Here 8888 is the starting port, and 10 means that all ports 8888-8898 must be moved out of the reserved ports. If you only want 8888 not to be used as a port, then 10 can be changed to 1.

After executing this command, restart and query the reserved ports again. You will find that a * will appear at the end of the port list. At this time, these ports will not be reserved for use.

The above is the detailed content of Solution to Windows system port being occupied, reasons why the port is occupied. For more information, please follow other related articles on the PHP Chinese website!

source:20hn.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template