Browsed by
Tag: Port

Apache service not starting on Window 10

Apache service not starting on Window 10

Having problems starting the Apache service on Windows 10? Probably port 80 is used by another process.

When you check which process is using port 80 (use Resource Monitor), it probably is the ‘System’ process (PID=4).

Resource Monitor

This means that a process by default installed and started by Windows is using port 80. Big chance that the ‘World Wide Web Publishing Service’ is running. Just stop it and set the Startup Type to ‘Manual’

e World Wide Web Publishing Service

Now try starting the Apache service again. If it is running, the Resource Monitor should now show that the ‘httpd.exe’ process is using port 80.

Resource Monitor

How to disable System service from listening to port 80

How to disable System service from listening to port 80

When you try to run Apache (or any other web server service), it can happen that Windows is not allowing to start it, because port 80 is already in use. To find out which process is using port 80, you can use the Resource Monitor (just run resmon.exe). Open the ‘Network’ tab and open the ‘Listening Ports’ section.

Resource Monitor

Another way to find out is to use ‘netstat -a -n -o | find “:80”‘.

How to solve the problem

If the process is just a ‘normal’ process, you just need to stop the associated service to free port 80. If it’s the System process (PID=4), that is using port 80, then we need to disable http.sys.

There are two ways to disable it:

  1. Go to device manager, select ‘View -> Show hidden devices’, go to ‘Non-plug and Play Driver -> HTTP’ and double click it to disable.
  2. Launch RegEdit, go to ‘HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP‘ and change to value of ‘start‘ to 4.
    After this you need to reboot your computer.

The following values are valid for the ‘start’ property:

0 Boot
1 System
2 Automatic
3 Manual
4 Disabled

 

See what process is using a TCP port

See what process is using a TCP port

In some cases you want to know which process is using a certain TCP port. By running the following command can determine which process is using which port:

[text]

netstat -a -n -o

[/text]

You will see an output like this:

[text highlight=”16″]
Active Connections

Proto Local Address Foreign Address State PID
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:81 0.0.0.0:0 LISTENING 11464
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 844
TCP 0.0.0.0:443 0.0.0.0:0 LISTENING 2620
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:554 0.0.0.0:0 LISTENING 5124
TCP 0.0.0.0:902 0.0.0.0:0 LISTENING 3396
TCP 0.0.0.0:912 0.0.0.0:0 LISTENING 3396
TCP 0.0.0.0:2103 0.0.0.0:0 LISTENING 2220
TCP 0.0.0.0:2105 0.0.0.0:0 LISTENING 2220
TCP 0.0.0.0:2107 0.0.0.0:0 LISTENING 2220
TCP 0.0.0.0:2869 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING 10232
TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING 1408
TCP 0.0.0.0:5050 0.0.0.0:0 LISTENING 12904
TCP 0.0.0.0:5357 0.0.0.0:0 LISTENING 4
[/text]

If for example you are looking for the process that is using port 3306, than in this example this would be the process with PID 10232. By using the Windows Task Manager you could find the process using this port.

Another way to find the process would be using the tasklist command:
[text]
tasklist /svc /FI “PID eq 10232″
[/text]

The result of this command tells us that the MySQL daemon is using port 3306:

[text highlight=”3″]
Image Name PID Services
========================= ======== ==============
mysqld.exe 10232 asterix
[/text]

When you do a lot of these port searches, you can always create a script like this:

[text highlight=”8,16”]
@echo off

REM Check arguments
if (%1) == () goto usage

REM Find the process using the given port
set pid=
netstat -a -n -o | findstr %1 > port.txt
for /F “tokens=5” %%a in (port.txt) do set pid=%%a
del port.txt

REM Check if a process was found using the given port
if (%pid%) == () goto notfound

REM Show the process using the given port
tasklist /svc /FI “PID eq %pid%”
goto end

:usage
REM Show usage message
echo.
echo USAGE: %0 [port]
echo.
goto end

:notfound
REM Given port is not in use
echo.
echo Port %1 is not used
echo.
goto end

:end
[/text]