Remove Virtual Host from Hosts File

  • | 1055 points


    First I want to say thanks for this awesome tool, really help beginners like me to have a good development environment on Windows machine.

    I want to ask how to remove virtual host entry from the Hosts file and httpd-vhosts.conf?
    For example, I created a simple native PHP project inside C:\laragon\www\myproject to try Laragon.
    Note: the project's name is myproject.

    Laragon then automatically create virtual host so myproject url became

    The Hosts file then have this line: #laragon magic! C:/laragon/www/myproject/

    And also there is few lines at C:\laragon\bin\apache\apache-2.4.17\conf\extra\httpd-vhosts.conf.

    But when I delete myproject from C:\laragon\www\ that line not removed from my Hosts file and httpd-vhosts.conf.

    How to remove those lines from Hosts file and httpd-vhosts.conf?
    Is it safe to just delete them both manually?

    Thank you

  • administrators
    | 131219 points

    Yes, it's totally safe :)

  • | 1055 points

    So just to be clear, to completely remove a project and it's virtual host, I need to do this steps:

    1. Delete the project's folder from www (www/myproject)
    2. Go to httpd-vhosts.conf and remove these lines:
      <VirtualHost *:80> #laragon magic!
      DocumentRoot "C:/laragon/www/myproject/"
    3. Go to drivers/etc/hosts and remove: #laragon magic! C:/laragon/www/myproject/

    Am I correct?

  • administrators
    | 131219 points

    Yes, you're correct!

    You can only do Step 1. Next time, when you put new folder in www, Laragon will clean 2, 3 for you.

  • | 1055 points

    I see, thanks Leo.

    After a few tests, I want to note this for future reference if I forgot, and for anyone else having this same question :)

    So, Laragon will auto remove deleted project's virtual host settings from Hosts and httpd-vhosts.conf when you add a new project to www folder.

    For example, you currently have project A, B, and C in www folder.
    Then you delete project A and B.
    The Hosts file and httpd-vhosts.conf will stay the same as before.
    But when you add a new project, lets say X, Laragon will remove virtual host settings for A and B from Hosts and httpd-vhosts.conf, then make a new virtual host for X.

    So as we can see, Laragon can make virtual host for new project, and auto remove it when its project deleted from www folder.

Log in to reply

Looks like your connection to Laragon was lost, please wait while we try to reconnect.