The other day I decided to install EasyPHP (a WAMP package that includes PHP, Apache, MySQL) on my machine running Windows 7. After install I ran the application, but to my surprise, Apache server was not working. It complained that Port 80 is used by another application. I thought this issue would be easily solved, but it took me a while to figure out what exactly is causing the problem. In this article I will show you what I tried and how I finally solved the Apache problem of not being able to run.
The error message that the EasyPHP gave was this:
I tried to start server manually but that gave me the following error:
make_sock: could not bind to address 127.0.0.1:80
no listening sockets available, shutting down
I could of course just change the port, but I really wanted to find out what is causing this problem.
EasyPHP error message suggested to locate cports.exe to find the culprit, but I decided to first check the Programs and Features in control panel to see if I can figure out why the Apache server cannot listen to default port 80.
Using Programs and Features to look for application causing the issue
Looking at the list of installed programs I quickly found one such application that might be causing this issue. It was IIS Express 8 which was installed long time ago and I have totally forgotten about it. So solution seemed simple. Uninstall IIS Express 8 and the issue will go away, but to my surprise, that still didn’t solve the problem at all. Starting Apache failed again with the same port 80 is busy problem. So I decided to take advice from that EasyPHP error message about using cports.exe.
Running CurrPorts (cports.exe) as the error message suggested
CurrPorts is a little utility that lists all currently opened TCP/IP and UDP ports and the processes that opened those ports. If you also have EasyPHP installed, you should already have this utility. On my machine running Windows 7 64-bit I located cports.exe at:
C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\binaries\tools\cports\
When I ran the cports.exe I got a list processes listening to different ports and there was one listening to port 80, but unfortunately for me, there was no useful information about which process is doing this as shown below:
For Process Name it showed System while Process ID showed 4. Even the option Kill Processes Of Selected Ports was grayed out.
Since currPorts was not giving me the information needed I decided to try my luck with commands in command prompt.
Using netstat command from Command Prompt
The one I tried first was netstat
, a command showing network activity.
Looking at the available parameters, using those listed below seemed worth a try
- -a : Displays all connections and listening ports.
- -n : Displays addresses and port numbers in numerical form.
- -o : Displays the owning process ID associated with each connection.
- -b : Displays the executable involved in creating each connection or listening port. (Requires administrator permission)
Due to –b parameter, I had to run cmd as an administrator as shown below:
Then I typed:
netstat –anob | more
netstat
to the next command (in our case more
) which is a pager that displays a content one screen a time. Press space bar to scroll to the next page.Looking for :80 under Local Address column I had this:
Local Address: | 0.0.0.0:80 |
---|---|
Foreign Address: | 0.0.0.0 |
State: | Listening |
PID: | 4 |
and below all these, there was a message “Can not obtain ownership information”.
PID stands for Process ID with PID 4 being a System Process where most system processes originate from. I tried to use Process Hacker utility to look for any information that would point me to what is causing this problem but I didn’t find any.
So I decided to try another command net stop which is discussed next.
Using net stop command from command prompt
Command net stop <service>
stops a running service. If that service has other services that depend on it, it will output a list of these services and prompts you for confirmation. This seemed like a great way to check what services depend on http service, so I typed the following line:
net stop http
The goal here was not to stop http service, so I didn't confirm when prompted for confirmation. Instead, I just wanted to get the list of services that use it. The list I received is shown below:
By individually stopping each service in the generated list (by using services.msc), I wanted to find out if any of these services are responsible for taking away port 80. When particular service was stopped and had no effect on Apache, I chose the next service in the list.
After stopping all the services in the list I was still getting the error, so I went back to the web looking for possible causes and what caught my attention was http.sys process which is discussed next.
Quick guide on how to stop and disable the service
- Open the Start Menu, search for services.msc in the search box and run it. The new window will show up with a list of all the services.
- To stop a service, find the one you are looking for, right-click on it and select Stop. To make sure, the service stops even after computer restart, disable the service all together.
- To disable the service, right-click on that service, choose Properties and under General Tab for option Startup type, select Disabled in dropdown menu and click OK. Before disabling the service, you might want to find out first what role the service has, just to make sure you don’t really need it.
Finding out processes that use http.sys
Http.sys is a driver that enables multiple processes to listen to HTTP traffic on the same port. But examining this driver in Task Manager and also on Process Hacker revealed no useful information relating to ports.
And then I stumbled upon HttpSysManager tool. This looked like a very promising little utility that might reveal what is blocking Apache to listen on the default port. I ran the application, selected Acls tag and found some prefixes with port 80 on it as shown below:
Two of them were for SQL Reports. I quickly checked the list of services and found SQL Server Reporting Services (SSRS). After I stopped it Apache was able to run without error.
There was still one thing to check up. I wondered if this SQL Reporting service was the only culprit or will any of the stopped services from the net stop http
list still cause problems. By restarting all those services the Apache was unable to run once again. In the end it turned out that besides SQL Server Reporting Service I also had to disable World Wide Web Publishing Service (W3SVC). After those two were disabled, port 80 was finally available for Apache.
Conclusion
If Apache won’t start on port 80, we can either set it to listen to another port, or we can try to locate the application or service and stop them if they are not needed. With the help of CMD commands and various utilities this can be an easy task, but if the Process listening to port 80 is System Process with PID 4, then it takes a little more effort.
I hope you found the information here useful. If so, consider dropping a comment or share the post on social networks.
Martyn
September 28, 2015Thank you so much for this mate. Saved me hours of frustration. 🙂
Sercan Leylek
January 11, 2016Just stop the "Web Deployment Agent Service" and it will work 🙂
Humberto Reis
February 26, 2016Thank you very much friend!! couldnt find anywhere! =D
susan
July 5, 2016Thank you for all of this helpful information. The first thing I tried was Sercan's comment, 'stop the Web Deployment Agent Service'. Ampps started without error. Very nice!
essay
July 19, 2016The Web Deployment Agent Service is not listed in Services
admin
July 19, 2016Then it is something else causing the port 80 problem. Check if there is World Wide Web Publishing Service (W3SVC) in the list.
Paul
December 16, 2016Great detective work! I also had to stop SQL Server Reporting Services in addition to World Wide Web Publishing Service since I installed SQL Server on my Windows 10 machine.
alg
May 9, 2017Stopping "SQL Server Reporting Services" did it for me. thank u.
Ganesh chapa
December 22, 2016Also found if your Skype found to be active. Then the same error comes in. Just logged out from Skype and found to be the issue got resolved.
Emma
January 7, 2017Thank you so, so much!
Segun
May 4, 2017Thank you so much,
I killed the World Wide Web Publishing Service (W3SVC) and Ampps start working.
Kumar Vishnu
March 17, 2021worked for me too mate thank u so much
Marc
May 7, 2018Hello, they will have the Http SysManager program go to the web to download it but they only download files
admin
May 7, 2018Thank you for pointing out that the download link doesn't work anymore, since CodePlex has shutdown. There is a version on a GitHub. but it doesn't have any releases, so you need to build it yourself.
Per
October 17, 2019That is truly amazing work. Thank you for sharing!
Lex
January 18, 2021Thank you! This worked with MAMP attempting to use port 80 for Apache. SSRS is the culprit haha