Join David Gassner for an in-depth discussion in this video Handling other port conflicts on Windows, part of Installing Apache, MySQL, and PHP.
- As I've previously described, you can only have one copy of MySQL and one copy of Apache listening to each of these ports at a time. If you try to install more than one copy of a server and point both copies at the same port, you'll get a port conflict. I'm going to show you how to recognize, and then how to resolve, port conflicts on Microsoft Windows. I currently have the Local Services control panel opened, and it shows here that Apache 2.4 is running.
And I'll type M Y and show that the MySQL service is also running. I've also installed WampServer on this computer, one of the more popular AMP stacks for Windows. I'll go to my system tray and show that the WampServer icon is red, meaning that the services aren't currently running. I'll try to start all services, and then I'll watch the icon. If the icon turns green, that means the services are running.
But this doesn't work, because WampServer's versions of the software are trying to use the same ports. Now I'll go back to my Services console, and I'll stop MySQL, and then I'll stop Apache. And then I'll go back down to my system tray, and I'll once again try to start all services for WampServer, and this time the icon turns green. And if I try to go to localhost, I get the WampServer homepage, and if I go to phpmyadmin, I see the MySQL server that's a part of WampServer.
Now, there are going to be times when you have services running you don't even know about, and it's important to know how to find out which services are using a particular port. I'm going to stop the WampServer services. I'll go to the Admin menu and say Stop All Services. Then I'll restart the individual components using the Services control panel. Then I'll show you a trick you can do on the command line to find out whether certain ports are in use and which applications are using them.
I'm going to go to the Command Prompt, and I'll work here as Administrator. Most of what I'm going to show you can be done either as Administrator or as a normal user, but I typically just start off with Administrator status. In the command line, I'm going to use an application that's included with all recent versions of Windows named Netstat. And I'll use Netstat with the parameter of -a, which means, "show me all server applications "listening on the TCP/IP stack." Then after netstat -a, I'll type in a pipe character, and then I'll use the Find application.
I'm going to look for a particular string that's returned by Netstat. You have to wrap the string in quotes. So this is the entire command: netstat -a, and then find the term "LISTENING" in the results. And here is the result. It shows me all the processes that are listening, regardless of which port they're using. Notice that I get two sets of results, one for IPv4 addresses, and down at the bottom, one for IPv6 addresses.
But these are the same processes. Now, if I want to filter for a particular port, I can execute the same command, but then I can filter it again. I'll press the up arrow key to bring back the last command, and then I'll append to the end of that another pipe character, then once again find, and this time I'll add in ":80". I'll close that with another quote, and this time I only get back the processes that are listening for that particular port.
Once again, I'm getting two versions, one for IPv4, and one for IPv6. The next step is to find out which exact process is using the port you're interested in. To do that, execute netstat again, but add in another parameter of -o. So now the full command is netstat -a -o | find "LISTENING" | find ":80". And now I get another column in the results, and it's giving me a numeric value.
That's the process ID. This ID is assigned by the computer when the process starts up. So it's probably going to be different on your computer than it is on mine. Now, I'm going to find out which process that is. I'll use the Task Manager for this. In Windows 8, I can get to Task Manager by going to the lower left corner, right clicking and choosing Task Manager. And in Windows 8, to get all the information I need, I'll click the More Details icon.
And that opens up the Task Manager. Next, I'll go to the Details tab. And this shows me all of my processes. I'll click the PID column to sort by that value, and then I'll scroll down, and I'll find the process, 3800. And this tells me that Apache HTTP Server is using this process, and that the name of the application is httpd.exe. So that's a look at how you can recognize port conflicts and find out which applications are using particular ports.
You can easily find out what's happening and then fix the situation if you know how to recognize the symptoms of a port conflict.
- Installing Apache, PHP, and MySQL separately
- Activating Apache and PHP on Mac OS X
- Installing and configuring phpMyAdmin
- Installing WampServer
- Installing MAMP
- Configuring MAMP's Apache and MySQL server ports
- Installing XAMPP for Windows and Mac OS X
- Managing MySQL security through XAMPP
- Installing Bitnami for Windows and Mac
- Detecting and handling port conflicts
- Working with Apache and IPv6 in Windows 8