Only one server process can listen on each port on a single computer. Learn about how to track down port conflicts on Microsoft Windows.
- [Man] As I've previously described, you can only have one server application listening on a particular port at a time. You can run multiple HTTP servers, but each needs to listen on a unique port. If more than one tries to run at the same time, you get a port conflict. I'll show you how to recognize and then how to resolve a port conflict on Microsoft Windows, and I'll do this with Apache. I've installed Apache as a service, and you can see here that it's running because you see the stop and restart links appear. I've also installed WampServer, and I'll go to the WampServer administration menu and try to start all services. I'll wait a few moments, but then I'll find that only two of the three services are running. And that's because the instance of Apache that's bundled with WampServer wasn't able to start up. Now, if you already know where the conflict is, you can fix it just by closing down the other service, but sometimes it's a mystery, and I'm going to show you a trick that lets you find out what's listening on a particular port. To do this, I'll go into a command window, I'll press Command + R, and type CMD, and then click okay or press enter. Now, you can do this either in a command window, or in PowerShell. I'll type netstat -a -o | find "LISTENING", and I see a list of all applications that are listening on all ports. The row at the top is listening on port 80. Notice the numeric value in the last column, that's called the process ID, and you can use that value to find the application that you're looking for, and you can use that value to find and shut down the process, if you need to do it that way. To stop the netstat command, press Control + C, and I'll show you one other trick to filter this a little more because on some computers you'll get dozens of services. After this string I'll add another pipe character, and then once again a find command, and this time I'll look for :80, and now I only see the service that's listening on that one port. So, on my system, this is on process ID 9072, it will be different on yours. To find this issue, I'll right click on the taskbar, and choose the task manager. When the task manager first opens up on Windows 10, it might look like this, but you'll want to click the more details link, to open up the entire screen. Then up here, click on the details tab, and you'll see a table that shows all of your processes, and there will be a PID column. The location of the PID column may differ, it may not be in this position on your computer, so if you don't see it, just expand the window until you see everything. Now going back to my command window, I was looking for process ID 9072, so I've sorted by the process ID, and I'll scroll all the way down, and I'll look for that process, and sure enough, it's httpd.exe, and that's the Apache HTTP server. Now again, if you already know which service it is, and how to shut it down, you really should do it that way. So, I could go to the services pane in the control panel, and just click the stop link, but sometimes it's a little bit more mysterious than that, and so here's how you can close down the process from within the task manager. Right click on the process, choose end task, and then confirm, and after a moment, the process should shut down. Then, you can go to the other service, and try again. I'll click on start all services, after just a moment the WampServer icon goes green, and when I move the cursor over it, I see the message all services running, and then I'll use the menu again, and go to localhost, and I see that this instance of Apache is now working correctly. So the netstat command can be used to find any port conflict, and then you can use the task manager to track down the process, and if necessary, you can kill it from there.
- Installing Apache on Windows
- Working with PHP on Windows and macOS
- Installing MySQL on Windows and macOS
- Starting and stopping Apache on macOS
- Installing Apache, PHP, and MySQL on Ubuntu Linux
- Installing and managing WampServer
- Defining WampServer directory aliases
- Installing MAMP on macOS
- Configuring Apache and MySQL server ports on MAMP
- Handling port conflicts on Windows and macOS
- Resetting the root admin password for MySQL