I've hit a bit of a block and need some help.

I have already set up my httpd.conf file to enable Virtual Hosts. I also set up httpd-vhosts.conf with a bunch of vitual hosts. I've been using them and they work fine (this is on my dev machine, not a live server.)
I started working on a new site. The first thing I did was set up a virtual host for it on my dev machine so I can navigate to it in my browser and test it quickly and easily.
The browsers won't find it! What could I be doing wrong? The following is my old httpd-vhosts.conf.
(Sorry for the long code snippets, but maybe seeing what I'm using will help solve my problem?)

NameVirtualHost 127.0.0.1:80

# Localhost
<VirtualHost 127.0.0.1:80>
    ServerName localhost
    
    # Indexes + Directory Root.
    DirectoryIndex index.html index.php
    DocumentRoot "/Developer/WebDev"
</VirtualHost>


# BowandCello.dev
<VirtualHost 127.0.0.1:80>
    DocumentRoot "/Developer/WebDev/bowandcello.com/www"
    ServerName bowandcello.dev
</VirtualHost>


# CenterForTraditionalMedicine.dev
<VirtualHost 127.0.0.1:80>
    ServerName CenterForTraditionalMedicine.dev
    
    # Indexes + Directory Root.
    DirectoryIndex index.html index.php
    DocumentRoot "/Developer/WebDev/CWIS/CenterForTraditionalMedicine.org/public"
</VirtualHost>


# CWIS.dev
<VirtualHost 127.0.0.1:80>
    ServerName cwis.dev
    
    # Indexes + Directory Root.
    DirectoryIndex index.html index.php
    DocumentRoot "/Developer/WebDev/CWIS/cwis.org"
</VirtualHost>


# DaveeC.dev
<VirtualHost 127.0.0.1:80>
    ServerName daveec.dev
    
    # Indexes + Directory Root.
    DirectoryIndex index.html index.php
    DocumentRoot "/Developer/WebDev/daveec.com/www"
</VirtualHost>


# DianoGarcia.dev
<VirtualHost 127.0.0.1:80>
    ServerName dianogarcia.dev
    
    # Indexes + Directory Root.
    DirectoryIndex index.html index.php
    DocumentRoot "/Developer/WebDev/dianogarcia.com/www"
</VirtualHost>


# digRecords.dev
<VirtualHost 127.0.0.1:80>
    DocumentRoot "/Developer/WebDev/digrecords.com/www"
    ServerName digrecords.dev
    
    # Indexes + Directory Root.
    DirectoryIndex index.html index.php
</VirtualHost>


# GretchenYanover.dev
<VirtualHost 127.0.0.1:80>
    ServerName gretchenyanover.dev
    
    # Indexes + Directory Root.
    DirectoryIndex index.html index.php
    DocumentRoot "/Developer/WebDev/gretchenyanover.com/www"
</VirtualHost>


# HealthAlt.dev
<VirtualHost 127.0.0.1:80>
    ServerName healthalt.dev
    
    # Indexes + Directory Root.
    DirectoryIndex index.html index.php
    DocumentRoot "/Developer/WebDev/CWIS/HealthAlt.org/html"
</VirtualHost>


# JonRyser.dev
<VirtualHost 127.0.0.1:80>
    ServerName jonryser.dev
    
    # Indexes + Directory Root.
    DirectoryIndex index.html index.php
    DocumentRoot "/Developer/WebDev/jonryser.com"
</VirtualHost>

  <VirtualHost 127.0.0.1:80>
      ServerName comics.jonryser.dev
    
      # Indexes + Directory Root.
      DirectoryIndex index.html index.php
      DocumentRoot "/Developer/WebDev/jonryser.com/comics.jonryser.com/public"
  </VirtualHost>


# LummiFutures.dev
<VirtualHost 127.0.0.1:80>
    ServerName lummifutures.dev
    
    # Indexes + Directory Root.
    DirectoryIndex index.html index.php
    DocumentRoot "/Developer/WebDev/CWIS/LummiFutures.com/www"
</VirtualHost>


# Scalfati.dev
<VirtualHost 127.0.0.1:80>
    ServerName scalfati.dev
    
    # Indexes + Directory Root.
    DirectoryIndex index.html index.php
    DocumentRoot "/Developer/WebDev/scalfati.old/public"
</VirtualHost>

Here is what I've added:

<VirtualHost 127.0.0.1:80>
      ServerName scadmin.dev

      # Indexes + Directory Root.
      DirectoryIndex index.html index.php
      DocumentRoot "/Developer/WebDev/scadmin.dev/public"
  </VirtualHost>

No matter where I put it in relation to the other virtual host blocks, once I restart apache and look up scadmin.dev in my browser, I get a server not found error.

Any thoughts and help is greatly appreciated!

Cheers

Dani AI

Generated

The vhost config in the first post was fine — the missing piece was name resolution. As discovered, the browser complained because the OS could not resolve the new hostname to your machine. The hosts file is the usual, local way to map developer names to 127.0.0.1 (or ::1 for IPv6); edits take effect immediately for most programs. (man7.org)

Quick checklist to reproduce and debug the problem locally (run these from your dev machine):

# does the OS resolve the name?
ping scadmin.dev
dig +short scadmin.dev    # or: nslookup scadmin.dev

# is Apache actually seeing the vhost?
sudo apachectl -S

# test request and headers
curl -I http://scadmin.dev

If the name is missing from the hosts file, add it and re-run the commands above; if Apache does not list the vhost, ensure the vhost file is included and run a config test (apachectl -t) before restarting. (httpd.apache.org)

One important modern caveat: do not rely on the “.dev” suffix for local HTTP-only sites. .dev is a real Google-operated gTLD and is treated by browsers as HTTPS-only via HSTS preload, so plain HTTP requests will be forced to HTTPS. For local work prefer reserved/testing names such as .test, .localhost or use a real local domain you control (or run HTTPS locally). (iana.org)

Example hosts entries you can add (requires admin privileges):

127.0.0.1   scadmin.dev www.scadmin.dev
::1         scadmin.dev

Also check IPv6 behavior (some systems prefer ::1), run a DNS cache flush appropriate to your OS if changes don’t appear, and remember Apache 2.4 no longer requires the NameVirtualHost directive (it is ignored/warned about). These small checks normally resolve the “server not found” symptom quickly. (man7.org)

(Thanks to for posting the original problem and to for the encouragement.)

I figured it out. I had to add the new virtual domains to the "hosts" file located in /private/etc.
Now it all works!

It good to know that you were able to find the solution on your own. Good Job!
Keep it up.

It good to know that you were able to find the solution on your own. Good Job!
Keep it up.

Thanks for the support! I'm just doin' what I can.

Cheers,
BigTalk

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.