← All writing

Troubleshooting Port 80 Conflicts with Apache on your newly installed WSL

· 5 min read

The problem

You have run into a situation where something is already using port 80 on your system, and it turns out Apache is the culprit. This is one of the most common stumbling blocks for developers setting up local servers - especially if you have just installed WSL and did not expect Apache to be there at all.

Port 80 is the default port for HTTP traffic, and most local development tools want it. DDEV, Lando, custom Docker setups - they all reach for port 80. When Apache is already sitting on it, nothing else can bind to it, and you get errors that are not always obvious about the root cause.

Why is this happening?

The output you are seeing indicates that the Apache web server is currently listening on port 80. This typically happens when Apache was installed as part of a package bundle or as a dependency of something else, and it started automatically. On Ubuntu and Debian-based systems, Apache binds to port 80 by default the moment it is installed - no configuration needed, no permission asked.

You can verify this yourself by running:

sudo lsof -i :80

If Apache is the process holding the port, you will see apache2 in the output. Now you know exactly what you are dealing with.

How to free up port 80

There are several ways to handle this, depending on whether you need Apache at all and how permanent you want the fix to be.

1. Stop the Apache service

If you do not need Apache running right now but might want it later, you can stop it temporarily. This frees up port 80 immediately but only until the next reboot or until something starts Apache again.

sudo service apache2 stop

Verify the port is free afterwards:

sudo lsof -i :80

If the output is empty, you are good to go.

2. Disable Apache from starting on boot

If you rarely need Apache and prefer to start it manually on the odd occasion you do, disable it from the boot sequence. This is the option I recommend for most developers who have moved to container-based workflows.

sudo systemctl disable apache2

This prevents Apache from launching at startup, meaning port 80 stays free unless you explicitly start Apache yourself. You can always re-enable it later with:

sudo systemctl enable apache2

3. Remove Apache entirely

If you have determined that you do not need Apache on your system at all, remove it. This is the clean option - no lingering services, no surprise port conflicts down the line.

sudo apt-get remove apache2

If you want to remove Apache along with its configuration files, use purge instead:

sudo apt-get purge apache2

Before doing this, make sure no other applications or services on your machine depend on Apache. If you are running WordPress locally through Apache, for instance, you will need an alternative in place first.

4. Change Apache's listening port

There is a middle ground that most guides do not mention. If you need Apache for some projects but also need port 80 free for other tools, you can change which port Apache listens on.

Open the ports configuration file:

sudo nano /etc/apache2/ports.conf

Find the line that reads Listen 80 and change it to another port - 8080 is the common choice:

Listen 8080

You will also need to update any virtual host files in /etc/apache2/sites-enabled/ that reference port 80. Then restart Apache:

sudo service apache2 restart

Now Apache runs on 8080 and port 80 is free for whatever else you need.

5. Restart Apache

Sometimes you do not need to stop or remove anything - you just need to reset Apache after a configuration change or if it is misbehaving.

sudo service apache2 restart

This does not free up port 80. It restarts Apache on the same port. Use this when you have edited Apache configuration files and need the changes to take effect.

6. Check and update your WSL version

If you are running your development environment on WSL, the port conflict might not be Apache's fault at all. Older or pre-release versions of WSL can cause unexpected behaviour with port forwarding between Windows and the Linux subsystem.

Check your current WSL version:

wsl --version

If the version is outdated or you are on a pre-release build, update it:

wsl --update

I would recommend staying on the stable release unless you have a specific reason to run pre-release. If you do need the latest fixes that have not hit stable yet:

wsl --update --pre-release

It is also worth checking whether something on the Windows side is holding port 80. Hyper-V, IIS, or even Skype have been known to grab it. From PowerShell on the Windows side:

netstat -ano | findstr :80

Which option should you choose?

It depends on your setup. If you use DDEV or another container-based tool for all your local development, just disable Apache from starting on boot and forget about it. That is what I do on my own machines. If you still have projects that rely on Apache directly, change its listening port to 8080 so it coexists with your other tools. If you are certain you will never need Apache, remove it entirely and keep things clean.

The bigger picture

This kind of port conflict is exactly why container-based development tools like DDEV exist. Instead of managing Apache, MySQL, PHP versions, and port assignments manually on your host system, you let containers handle all of it in isolation. Each project gets its own environment, its own ports, its own configuration - and nothing conflicts with anything else.

If you are still running a traditional LAMP stack on your local machine for Drupal or WordPress development, consider making the switch. I wrote about setting up DDEV in another post, and it eliminates this entire category of problems.

But for now - stop Apache, free the port, and get back to work.