Wamp Server Virtual Host Not Working – A Guide for Devs

Dear Dev, if you are here, then you might be facing issues with your Wamp server virtual host not working. Do not worry, in this article we will go over the reasons behind the issue and the solutions to fix it. So without further ado, let’s get started.

Understanding Wamp Server

Wamp Server is a software that helps developers run PHP, MySQL, and Apache on their local machine. It provides a convenient environment for developers to work on their web development projects without the need for an online hosting service.

One of the most common use cases for Wamp Server is to run multiple virtual hosts for different projects. However, sometimes virtual hosts may stop working, causing developers to lose precious time in troubleshooting the issue.

Reasons Behind Virtual Host Not Working

There are several reasons why a virtual host in Wamp Server may stop working:

Reasons
Solutions
Incorrect Virtual Host Configuration
Correct the virtual host configuration.
Port 80 being used by another application
Find the application using Port 80 and change its port number.
Firewall blocking Wamp Server
Add Wamp Server to the list of allowed applications in the firewall settings.
Apache Web Server not running
Start the Apache Web Server.
Hosts file not configured correctly
Edit the hosts file to add virtual host configuration.

Solutions to Fix Virtual Host Not Working

1. Correct the Virtual Host Configuration

The first step in fixing a virtual host not working issue is to check if the virtual host configuration is correct or not.

The virtual host configuration can be found in the httpd-vhosts.conf file in the Apache configuration directory. The path to the file is usually: C:\wamp64\bin\apache\apache2.4.37\conf\extra\httpd-vhosts.conf.

Make sure that the configuration is correct and there are no syntax errors. If there are errors, fix them and restart the Apache server.

2. Find the Application using Port 80 and Change its Port Number

Another reason why the virtual host may not be working is that Port 80 is being used by another application. To find the application, open the command prompt and run this command:

netstat -ano | findstr :80

This command will list all the applications using Port 80. If you find an application that is not required, you can either close the application or change its Port number.

To change the Port number, open the application configuration and look for the Port setting. Change the Port number to any number above 1024 and save the configuration. Restart the application and the Apache server.

3. Add Wamp Server to the List of Allowed Applications in Firewall Settings

Sometimes, the Windows Firewall can block Wamp Server, causing virtual host not working issues. To add Wamp Server to the list of allowed applications, follow these steps:

1. Open the Control Panel and go to System and Security.

2. Click on Windows Defender Firewall.

3. Click on Allow an app or feature through Windows Defender Firewall.

4. Click on Change settings and then click on Allow another app.

5. Browse to the location of the Wamp Server and add it to the list of allowed applications.

6. Restart the Apache server.

READ ALSO  Server Hosting cPanel: The Ultimate Guide for Devs

4. Start the Apache Web Server

Sometimes, the Apache Web Server may not be running, causing virtual host not working issues. To start the Apache Web Server, open the Wamp Server and click on the Start button next to Apache.

5. Edit the Hosts File to Add Virtual Host Configuration

The hosts file is used to map hostnames to IP addresses. The hosts file can be found in the C:\Windows\System32\drivers\etc directory.

To add virtual host configuration, open the hosts file in Notepad and add the following lines:

127.0.0.1yourdomain.test

This line will map yourdomain.test to your local machine IP address. Now, add the virtual host configuration in the httpd-vhosts.conf file:

<VirtualHost *:80>
AH01630: client denied by server configuration:
        Require all granted
        DocumentRoot "c:/wamp64/www/yourdomain.test"
        ServerName yourdomain.test
</VirtualHost>

Make sure to replace yourdomain.test with your desired domain name. Save the files and restart the Apache server.

FAQs

Q. How do I know if my virtual host is running?

A. To check if your virtual host is running, open your web browser and type in the virtual host domain name. If the virtual host is running, you should see your website’s homepage.

Q. How do I troubleshoot errors in the virtual host configuration?

A. To troubleshoot errors in the virtual host configuration, check the error logs in the Apache log directory. The path to the log directory is usually C:\wamp64\bin\apache\apache2.4.37\logs.

Q. Can I run multiple virtual hosts on Wamp Server?

A. Yes, you can run multiple virtual hosts on Wamp Server. To create a new virtual host, follow the same steps as outlined in this article and make sure to change the domain name and directory path.

Q. Can I use Wamp Server for production?

A. No, Wamp Server is not recommended for production use. It is only suitable for local development purposes.

Q. What is the default username and password for Wamp Server?

A. The default username and password for Wamp Server is “root” and no password.

Q. How do I change the default port number for the Apache Web Server?

A. To change the default port number for the Apache Web Server, open the httpd.conf file in the Apache configuration directory and look for the following line:

Listen 80

Change the number to any other available Port number and save the file. Restart the Apache server.

Conclusion

In this article, we went over the reasons behind Wamp Server virtual host not working issues and the solutions to fix them. We hope this guide has helped you fix your issue and get back to coding. If you have any further questions, feel free to leave a comment below.