[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"$f1JekbUKV14bVPHUXE5rTO8NJKQGChf4x8vrCP-BZfOU":3},{"id":4,"title":5,"teaser":6,"body":7,"slug":8,"date":9,"coverImage":10,"tags":15},"434f6027-3439-4ee6-9060-3de4a0d00ad1","Troubleshooting Port 80 Conflicts with Apache on your newly installed WSL","","\u003Ch2>The problem\u003C\u002Fh2>\u003Cp>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.\u003C\u002Fp>\u003Cp>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.\u003C\u002Fp>\u003Ch2>Why is this happening?\u003C\u002Fh2>\u003Cp>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.\u003C\u002Fp>\u003Cp>You can verify this yourself by running:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">sudo lsof -i :80\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>If Apache is the process holding the port, you will see apache2 in the output. Now you know exactly what you are dealing with.\u003C\u002Fp>\u003Ch2>How to free up port 80\u003C\u002Fh2>\u003Cp>There are several ways to handle this, depending on whether you need Apache at all and how permanent you want the fix to be.\u003C\u002Fp>\u003Ch3>1. Stop the Apache service\u003C\u002Fh3>\u003Cp>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.\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">sudo service apache2 stop\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>Verify the port is free afterwards:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">sudo lsof -i :80\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>If the output is empty, you are good to go.\u003C\u002Fp>\u003Ch3>2. Disable Apache from starting on boot\u003C\u002Fh3>\u003Cp>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.\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">sudo systemctl disable apache2\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>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:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">sudo systemctl enable apache2\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch3>3. Remove Apache entirely\u003C\u002Fh3>\u003Cp>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.\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">sudo apt-get remove apache2\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>If you want to remove Apache along with its configuration files, use purge instead:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">sudo apt-get purge apache2\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>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.\u003C\u002Fp>\u003Ch3>4. Change Apache's listening port\u003C\u002Fh3>\u003Cp>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.\u003C\u002Fp>\u003Cp>Open the ports configuration file:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">sudo nano \u002Fetc\u002Fapache2\u002Fports.conf\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>Find the line that reads \u003Ccode>Listen 80\u003C\u002Fcode> and change it to another port - 8080 is the common choice:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-apache\">Listen 8080\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>You will also need to update any virtual host files in \u003Ccode>\u002Fetc\u002Fapache2\u002Fsites-enabled\u002F\u003C\u002Fcode> that reference port 80. Then restart Apache:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">sudo service apache2 restart\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>Now Apache runs on 8080 and port 80 is free for whatever else you need.\u003C\u002Fp>\u003Ch3>5. Restart Apache\u003C\u002Fh3>\u003Cp>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.\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">sudo service apache2 restart\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>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.\u003C\u002Fp>\u003Ch3>6. Check and update your WSL version\u003C\u002Fh3>\u003Cp>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.\u003C\u002Fp>\u003Cp>Check your current WSL version:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">wsl --version\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>If the version is outdated or you are on a pre-release build, update it:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">wsl --update\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>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:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-bash\">wsl --update --pre-release\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>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:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-powershell\">netstat -ano | findstr :80\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch2>Which option should you choose?\u003C\u002Fh2>\u003Cp>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.\u003C\u002Fp>\u003Ch2>The bigger picture\u003C\u002Fh2>\u003Cp>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.\u003C\u002Fp>\u003Cp>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.\u003C\u002Fp>\u003Cp>But for now - stop Apache, free the port, and get back to work.\u003C\u002Fp>","troubleshooting-port-80-conflicts-apache-your-newly-installed-wsl","2024-08-23T17:50:34+00:00",{"id":11,"url":12,"alt":5,"width":13,"height":14},"9f0f787b-39d2-4e80-a85a-5bc688de44b9","\u002Fsites\u002Fdefault\u002Ffiles\u002F2024-08\u002FScreenshot%202024-08-17%20210044_0.png",637,668,[]]