This is a specific variation on the "can't connect" problem. In my case, I've just set up two virtual hosts in my httpd.conf listening on port 80. The declaration looks like:
NameVirtualHost *:80 <VirtualHost *:80> ServerName site1.dev DocumentRoot /www/site1 </VirtualHost> <VirtualHost *:80> ServerName site2.dev DocumentRoot /www/site2 </VirtualHost>
So from my understanding, http://localhost and http://site1.dev now both map to "/www/site1/" and of course http://site2.dev maps to its directory.
This is all well and good. I have a Wordpress installation I'm playing with currently under the site2.dev domain. I'm trying to configure it to work with the MySQL database I just set up which has an account "mysql" for "localhost." So in the configuration for Wordpress, I put in that username and the host name as "localhost." This doesn't work, so after playing with it for a while, I try changing the host name to "site2.dev" and suddenly it works fine.
What's going on here? I understand that my virtual hosts are setup, but I thought they were listening on port 80, not port 3306, which is what MySQL uses, so why does any of that matter? I'm sure there's a simple explanation, so hopefully someone can enlighten me.