Answers.Body: <p>Well, I can't really mark any of these as the answer, and I have no clue what actually did it, the config simply started working. I restarted all services and my machine many times during this process, so it was nothing quite so simple. I guess this is what I get for developing on a Windows machine. I considered deleting the question, but there's some valuable troubleshooting in the answers, so better to leave it live.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-24T16:34:22.047Z
Answers.Text: Thanks for reporting back! It's too bad there wasn't a clear solution, but good to know the resolution anyway.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-24T13:39:14.047Z
Answers.LastActivityDate: 2014-06-24T13:39:14.047Z
Answers.UserDisplayName: serquhart
Answers.Body: <p>The environment-specific array that Craft uses is determined by the $_SERVER['SERVER_NAME'] variable (usuall your <em>domain name</em>), not the database hostname. Instead of using <code>localhost</code> to trigger the env-specific settings, you should use your domain. Your db.php should looks more like this:</p>
  
  <pre><code>return array(
  
    // default
    '*' =&gt; array(
      'server' =&gt; 'localhost',
      'user' =&gt; 'av01759',
      'password' =&gt; '*******',
      'database' =&gt; 'av01759_maltaministries',
      'tablePrefix' =&gt; 'craft',
    ),
  
    // production-specific (use your domain instead of example.com)
    'example.com' =&gt; array(
      'server' =&gt; 'localhost:3307'
    )
  
  );
  </code></pre>
  
  <p><strong>UPDATE:</strong> Since in this case, $_SERVER['SERVER_NAME'] actually is "localhost" for you and I understand you are connecting to a remote db, you could try using this for your db.php (swapped the value for <code>server</code> in my above example, this way you make the exception for production).</p>
  
  <pre><code>return array(
  
    // default
    '*' =&gt; array(
      'server' =&gt; 'localhost:3307',
      'user' =&gt; 'av01759',
      'password' =&gt; '*******',
      'database' =&gt; 'av01759_maltaministries',
      'tablePrefix' =&gt; 'craft',
    ),
  
    // production-specific
    'production-site-domain-here.com' =&gt; array(
      'server' =&gt; 'localhost'
    )
  
  );
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:31:29.640Z
Answers.Text: Localhost is the domain for my local environment. Environment vars work simply by checking the $_SERVER['SERVER_NAME'] variable. For local development on my machine, that variable contains 'localhost'. So for Craft's setup, the '*' array provides default settings for every environment, and wherever the SERVER_NAME variable partially matches 'localhost', it should override the default server with the server provided in the 'localhost' array.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T21:19:21.243Z
Answers.Text: Yes, you're right I should have said use the value for $_SERVER['SERVER_NAME'] instead of "domain name" thanks (I fixed this in my answer). I see your point about your situation -- Are you able to create a virtual host for your site, like example.dev, so that you don't have to rely on "localhost" to trigger the environment specific settings? If not, see the update I added on my answer.
Answers.UserDisplayName: Alex Kendrick
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:25:56.883Z
Answers.LastActivityDate: 2014-06-19T20:53:03.210Z
Answers.LastEditDate: 2014-06-19T20:53:03.210Z
Answers.UserDisplayName: Alex Kendrick
Answers.Body: <p>When you are accessing a database "from a distance", it won't be called "localhost". Having the port in there is probably helpful, but you'll want to specify the DB server by its IP address.</p>
  
  <pre><code>'localhost' =&gt; array(
    'server' =&gt; '(DB IP address):3307'
  )
  </code></pre>
  
  <p>Also, be sure that your server database is allowing remote access. By default, most DBs will only allow access to their local files.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:23:06.420Z
Answers.Text: If I set the 'server' attribute in the '*' array to 'localhost:3307', it works. I just need to add the port, which I'm doing here for localhost, but Craft isn't recognizing it.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:24:27.013Z
Answers.Text: It works on your local machine, or on the remote server? "localhost" is supposed to mean local, which a remote server would not be.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:28:22.243Z
Answers.Text: It works everywhere, 'localhost:3307' for local development and 'localhost' for the live site. I'm using an SSH tunnel to access the remote database.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:30:27.910Z
Answers.Text: Ah, ok... that makes more sense.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:20:52.950Z
Answers.LastActivityDate: 2014-06-19T20:20:52.950Z
Answers.UserDisplayName: Lindsey D
Answers.Body: <p>This issue may be that your database name, prefix, password, etc are different on your local machine, than the ArcusTech server. If your local values don't match the values in the block defined with the asterisk, you won't be able to connect.</p>
  
  <p>Most local databases with tools like MAMP, use a default user and password like 'root'. Try to look into some of these values, or post more info about your local setup.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:06:37.003Z
Answers.Text: I'm logging into the live database remotely - not dealing with dueling databases. In other words, if I add port 3307 to the '*' array, it works.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:49:11.810Z
Answers.Text: Ah ok. I believe you would need the external IP to for where the MySQL DB is hosted. In this case, if you are using shared hosting on ArcusTech, this will not be your server IP. You might want to contact ArcusTech and ask how you might connect to MySQL with an external address.
  
  I don't think you are able to refer to their databases by anything but localhost, without that ext IP. Which in this case, would cause Craft to look at your machine for localhost.
  
  Hope this makes sense.
Answers.UserDisplayName: Bill Columbia
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:59:24.463Z
Answers.Text: I'm already successfully connecting to the database via SSH tunneling. For local development, I need to add the port, hence the added port under 'localhost' in my db config. Craft wouldn't look at my machine for localhost - it simply reads the value of the SERVER_NAME constant and compares that string to the string entered in db.php, which in this case is an exact match.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T21:05:17.253Z
Answers.Text: So you have it all working now by adding the port?
Answers.UserDisplayName: Bill Columbia
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T21:13:41.503Z
Answers.Text: I wish. The issue was never the _address_, it's getting Craft to recognize the server name.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T21:34:16.957Z
Answers.Text: So what I'm not understanding is, when you're on your machine, and craft sees that the server is localhost, it uses your config array specified for that. That config has 'server' set as 'localhost:3307', which on your machine, is localhost. It's trying to connect to YOUR_MACHINE:3307. It doesn't have an external server defined to get to your remote db. Localhost is relative to the box the code is running on. Does that make sense?
Answers.UserDisplayName: Bill Columbia
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T22:01:59.523Z
Answers.Text: He replied to my comment about that saying that he's using SSH tunneling to access the DB... so "localhost" would still work.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T22:09:09.353Z
Answers.Text: I saw that, but from my understanding that doesn't work with ArcusTech? Might be best solved by contacting their support?
Answers.UserDisplayName: Bill Columbia
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-20T01:31:49.530Z
Answers.Text: No, no, no - Craft doesn't care about what does and does not constitute 'localhost'. It's not checking DNS, it's simply checking the server_name variable and comparing that string to the string specified as your server in the db config. Which is why this so puzzling.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:01:44.787Z
Answers.LastActivityDate: 2014-06-19T20:01:44.787Z
Answers.UserDisplayName: Bill Columbia
Answers.Body: <p>If you're using MAMP you might also want to try using ".dev" or ".dv" for your array like so in your general.php config file:</p>
  
  <pre><code>'.dev' =&gt; array(
       'devMode' =&gt; true,
  ),
  </code></pre>
  
  <p>Versus using <code>localhost</code>.</p>
  
  <p>UPDATED Local / Live General.php file setup:</p>
  
  <pre><code>return array(
      '*' =&gt; array(
          'cpTrigger' =&gt; 'admin',
          'omitScriptNameInUrls' =&gt; true,
          'defaultFolderPermissions' =&gt; 0755,
          'phpMaxMemoryLimit' =&gt; '1024M',
          'useCompressedJs' =&gt; true,
          'useEmailAsUsername' =&gt; true,
          'autominEnabled' =&gt; true,
          'autominCachingEnabled' =&gt; true,
          'autominMinifyEnabled' =&gt; true,
      ),
      '.dev' =&gt; array(
          'devMode' =&gt; true,
          'environmentVariables' =&gt; array(
              'siteUrl' =&gt; 'http://www.DOMAINNAME.dev/',
              'basePath' =&gt; 'LOCAL PATH',
              'autominPublicRoot' =&gt; basePath,
              'autominCachePath' =&gt; basePath.'cache',
              'autominCacheURL' =&gt; '/cache',
          )
      ),
      '.com' =&gt; array(
          'devMode' =&gt; false,
          'environmentVariables' =&gt; array(
              'siteUrl' =&gt; 'http://www.DOMAINANME.COM/',
              'basePath' =&gt; 'SERVER BASE PATH',
              'autominPublicRoot' =&gt; basePath,
              'autominCachePath' =&gt; basePath.'cache',
              'autominCacheURL' =&gt; '/cache',
          )
      )
  );
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:07:20.413Z
Answers.Text: Using WAMP - $_SERVER['SERVER_NAME'] contains "localhost", so nothing else will match.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:18:40.197Z
Answers.Text: Check out my updated example. Are you setting up separate HOSTS in MAMP?
Answers.UserDisplayName: Mark Busnelli Jr
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:19:53.300Z
Answers.Text: Just saw your update - using tld's is just one approach, it really comes down to unique partial matches, which can look a number of different ways. As I stated, my local environment registers as 'localhost', so nothing else would work.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:20:34.363Z
Answers.Text: wamp, I'm using wamp. Hosts aren't an issue, I'm accessing the local site at 'localhost'.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:21:41.183Z
Answers.Text: I see. I use MAMP and that's just how I approach builds in different environments. Maybe you might consider updating your question with your exact setup so someone else can better understand and assist you.
Answers.UserDisplayName: Mark Busnelli Jr
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:24:54.163Z
Answers.Text: I didn't add the setup because it's unlikely to be relevant. My setup works as long as I indicate port 3307 in db.php. Craft is not recognizing my doing so for localhost.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:06:19.747Z
Answers.LastActivityDate: 2014-06-19T20:17:29.323Z
Answers.LastEditDate: 2014-06-19T20:17:29.323Z
Answers.UserDisplayName: Mark Busnelli Jr
Answers.Body: <p><code>'localhost'</code> is simply not recognized when using as a domain-specific db config block. You have to use the general <code>'*'</code>-block when serving your site via <code>http://localhost/</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-27T08:29:23.993Z
Answers.LastActivityDate: 2016-04-27T08:29:23.993Z
Answers.UserDisplayName: Lars Bilke
Answers.Body: <p>Another option is to use named environments instead of using domain matching.</p>
  
  <p>in your <code>index.php</code> file, just set (changing 'development' to whatever you like):</p>
  
  <pre><code>define('CRAFT_ENVIRONMENT', 'development');
  </code></pre>
  
  <p>Then your environmental config array can use "development" as a key, instead of <code>localhost</code> or <code>.dev</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:33:59.563Z
Answers.Text: Right, but if 'localhost' doesn't work, then assigning 'localhost' to an intermediate variable doesn't fix it. My initial setup attempted this and I bypassed it for troubleshooting.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-20T21:26:02.370Z
Answers.Text: I don't follow. If you set the CRAFT_ENVIRONMENT constant, it bypasses any domain matching, so if you wanted to set that to 'localhost' you could, and it works. But generally, you'd set this something like development, production, or staging.
  
  http://buildwithcraft.com/docs/php-constants#craft-environment
Answers.UserDisplayName: Tim Kelty
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-24T13:30:01.863Z
Answers.Text: Ah - I was using a script within index.php that dynamically assigns CRAFT_ENVIRONMENT based on the current environment. Statically assigning this variable seems to defeat the purpose of a multi-environment config, no?
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-25T12:04:02.860Z
Answers.Text: @serquhart, I include an environment.php file at the top of my index.php that sets the `CRAFT_ENVIRONMENT` variable. This file stays out of source control, so, e.g. on my production server, I have an `environment.php` file that sets `CRAFT_ENVIRONMENT` to "production". Likewise for any other environment.
Answers.UserDisplayName: Tim Kelty
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T20:26:28.193Z
Answers.LastActivityDate: 2014-06-19T20:26:28.193Z
Answers.UserDisplayName: Tim Kelty
Answers.Body: <p>This boils down to being either one of two things...</p>
  
  <ul>
  <li>A <strong>database connection error</strong>, or</li>
  <li>An <strong>environment detection error</strong>.</li>
  </ul>
  
  <p>You seem very convinced that the database connection info is perfect, so let's explore the possibility of an environment detection error.</p>
  
  <p>Please conduct this test... Edit your <strong>craft/config/general.php</strong> file, and add this configuration:</p>
  
  <pre><code>return array(
  
    '*' =&gt; array(),
  
    'localhost' =&gt; array(
      'devMode' =&gt; true
    )
  
  );
  </code></pre>
  
  <p>Now login to your Craft control panel... <strong>Do you see the yellow-striped "caution tape" at the top of your control panel?</strong></p>
  
  <p>If the answer is "yes", then your environment detection is working perfectly. Therefore, you have a database connection error.</p>
  
  <p>If the answer is "no", then you have an environment detection error. If this is the case, please answer this question:</p>
  
  <p><strong>Exactly what URL do you use to view your website on your local machine?</strong></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-20T01:33:47.733Z
Answers.Text: Hi Lindsey - it's not a database connection error. You troubleshoot that by making the desired server address the default and seeing if it works, which it does. The issue is Craft correctly determining the environment. The exact URL for local development is "localhost", or more accurately, http://localhost
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-20T01:36:48.153Z
Answers.Text: Did you conduct the test with config/general.php? I've never heard of anyone else having trouble like this with their environment being detected.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-20T01:38:27.863Z
Answers.Text: The database connection is precisely the same test that you're referring to, except instead of looking for yellow tape, I'm looking for a working database connection. The connection works perfectly fine if given the right server address. If the right address is under '*', it works. If it's under 'localhost', it doesn't. And I've never heard of anything like this either.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-20T01:41:35.137Z
Answers.Text: It sounds like you haven't conducted the "yellow tape" test, and I encourage you to take 2 minutes and try it. Based on the results of that test, we can give you further guidance.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-20T02:00:13.573Z
Answers.Text: Heh, you're persistent. I did it, no tape.
Answers.UserDisplayName: serquhart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-20T02:04:02.020Z
Answers.Text: Thanks. :)  Alright, so something is definitely screwed up with your environment detection... Whatever it is, it's not normal. At this point, the best advice anyone can give you is to contact support@buildwithcraft.com . Good luck, please let us know what the resolution ends up being!
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-19T22:11:32.830Z
Answers.LastActivityDate: 2014-06-19T22:11:32.830Z
Answers.UserDisplayName: Lindsey D
Body: <p>The <code>'localhost'</code> array is not being recognized. If I add <code>:3307</code> to the <code>'*'</code> array's server attribute, it works. Here's the contents of my db.php:</p>
  
  <pre><code>return array(
  
    '*' =&gt; array(
      'server' =&gt; 'localhost',
      'user' =&gt; 'av01759',
      'password' =&gt; '*******',
      'database' =&gt; 'av01759_maltaministries',
      'tablePrefix' =&gt; 'craft',
    ),
  
    'localhost' =&gt; array(
      'server' =&gt; 'localhost:3307'
    )
  
  );
  </code></pre>
  
  <p>This a fresh Craft install with no tweaks. Any ideas?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-19T20:28:15.193Z
Comments.Text: See my answer. Instead of 'localhost' you should use the domain name to trigger the correct environment-specific settings.
Comments.UserDisplayName: Alex Kendrick
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-19T20:34:07.797Z
Comments.Text: @serquhart Quick question... When you refer to your local machine as "localhost" in the /craft/config/general.php file, do those settings take effect? Trying to determine if this is a **database connection error** or an **environment detection error**.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-19T20:35:35.070Z
Comments.Text: @LindseyD I haven't even touched general.php - this is a fresh install. It's not a database connection error, because if I make the '*' array's server setting match the setting from the 'localhost' array, it works.
Comments.UserDisplayName: serquhart
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-19T20:41:34.793Z
Comments.Text: I understand... but we're trying to determine if your "localhost" block is even being picked up at all. Would you mind conducting a simple test? Duplicate this multi-environment configuration in general.php and add a simple config setting which would make it obvious that your "localhost" block is being recognized. Set a value like **[omitScriptNameInUrls](http://buildwithcraft.com/docs/config-settings#omitScriptNameInUrls) to false** and see if that change actually kicks in on your local site.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-19T20:45:11.293Z
Comments.Text: Even better, try turning on **[devMode](http://buildwithcraft.com/docs/config-settings#devMode)**. You'll know right away if that yellow caution tape appears at the top of your CP.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-19T22:13:11.437Z
Comments.Text: I posted this theory separately [as an answer...](http://craftcms.stackexchange.com/questions/318/multi-environment-database-config-being-ignored/327#327)
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-20T01:36:31.580Z
Comments.Text: See my comment on your answer. What's even weirder is that, when I transpose the configuration, making the local address the default and telling Craft to sniff for my live url as the environmental override, that doesn't work either. So it's not an issue inherent to the namespace 'localhost'. I'm pretty lost. All of that said, I also realized that I need to gitignore my database config, so this whole thing is sort of a wash. I'll just have two separate configs. Until I need general config to go environmental, that is.
Comments.UserDisplayName: serquhart
Tags: <environments>
Title: Multi-environment database config being ignored
ThreadText: # Multi-environment database config being ignored
  
  (Asked by: username_0 on 2014-06-19)
  
  The `'localhost'` array is not being recognized. If I add `:3307` to the `'*'` array's server attribute, it works. Here's the contents of my db.php:
  
  ```
  return array(
  
    '*' => array(
      'server' => 'localhost',
      'user' => 'av01759',
      'password' => '*******',
      'database' => 'av01759_maltaministries',
      'tablePrefix' => 'craft',
    ),
  
    'localhost' => array(
      'server' => 'localhost:3307'
    )
  
  );
  
  ```
  
  This a fresh Craft install with no tweaks. Any ideas?
  
  **Tags:** environments
  
  > **Comments:**
  > **username_1**: See my answer. Instead of 'localhost' you should use the domain name to trigger the correct environment-specific settings.  
  > **username_2**: @username_0 Quick question... When you refer to your local machine as "localhost" in the /craft/config/general.php file, do those settings take effect? Trying to determine if this is a **database connection error** or an **environment detection error**.  
  > **username_0**: @username_2 I haven't even touched general.php - this is a fresh install. It's not a database connection error, because if I make the '*' array's server setting match the setting from the 'localhost' array, it works.  
  > **username_2**: I understand... but we're trying to determine if your "localhost" block is even being picked up at all. Would you mind conducting a simple test? Duplicate this multi-environment configuration in general.php and add a simple config setting which would make it obvious that your "localhost" block is being recognized. Set a value like **[omitScriptNameInUrls](http://buildwithcraft.com/docs/config-settings#omitScriptNameInUrls) to false** and see if that change actually kicks in on your local site.  
  > **username_2**: Even better, try turning on **[devMode](http://buildwithcraft.com/docs/config-settings#devMode)**. You'll know right away if that yellow caution tape appears at the top of your CP.  
  > **username_2**: I posted this theory separately [as an answer...](http://craftcms.stackexchange.com/questions/318/multi-environment-database-config-being-ignored/327#327)  
  > **username_0**: See my comment on your answer. What's even weirder is that, when I transpose the configuration, making the local address the default and telling Craft to sniff for my live url as the environmental override, that doesn't work either. So it's not an issue inherent to the namespace 'localhost'. I'm pretty lost. All of that said, I also realized that I need to gitignore my database config, so this whole thing is sort of a wash. I'll just have two separate configs. Until I need general config to go environmental, that is.  
  
  ---
  
  ## 8 answers
  
  ### Answer by username_0 on 2014-06-24. Score: 2 | Accepted answer
  
  Well, I can't really mark any of these as the answer, and I have no clue what actually did it, the config simply started working. I restarted all services and my machine many times during this process, so it was nothing quite so simple. I guess this is what I get for developing on a Windows machine. I considered deleting the question, but there's some valuable troubleshooting in the answers, so better to leave it live.
  
  > **Comments:**
  > **username_2**: Thanks for reporting back! It's too bad there wasn't a clear solution, but good to know the resolution anyway.  
  
  ---
  
  ### Answer by username_1 on 2014-06-19. Score: 3
  
  The environment-specific array that Craft uses is determined by the $\_SERVER['SERVER\_NAME'] variable (usuall your *domain name*), not the database hostname. Instead of using `localhost` to trigger the env-specific settings, you should use your domain. Your db.php should looks more like this:
  
  ```
  return array(
  
    // default
    '*' => array(
      'server' => 'localhost',
      'user' => 'av01759',
      'password' => '*******',
      'database' => 'av01759_maltaministries',
      'tablePrefix' => 'craft',
    ),
  
    // production-specific (use your domain instead of example.com)
    'example.com' => array(
      'server' => 'localhost:3307'
    )
  
  );
  
  ```
  
  **UPDATE:** Since in this case, $\_SERVER['SERVER\_NAME'] actually is "localhost" for you and I understand you are connecting to a remote db, you could try using this for your db.php (swapped the value for `server` in my above example, this way you make the exception for production).
  
  ```
  return array(
  
    // default
    '*' => array(
      'server' => 'localhost:3307',
      'user' => 'av01759',
      'password' => '*******',
      'database' => 'av01759_maltaministries',
      'tablePrefix' => 'craft',
    ),
  
    // production-specific
    'production-site-domain-here.com' => array(
      'server' => 'localhost'
    )
  
  );
  
  ```
  
  > **Comments:**
  > **username_0**: Localhost is the domain for my local environment. Environment vars work simply by checking the $_SERVER['SERVER_NAME'] variable. For local development on my machine, that variable contains 'localhost'. So for Craft's setup, the '*' array provides default settings for every environment, and wherever the SERVER_NAME variable partially matches 'localhost', it should override the default server with the server provided in the 'localhost' array.  
  > **username_1**: Yes, you're right I should have said use the value for $_SERVER['SERVER_NAME'] instead of "domain name" thanks (I fixed this in my answer). I see your point about your situation -- Are you able to create a virtual host for your site, like example.dev, so that you don't have to rely on "localhost" to trigger the environment specific settings? If not, see the update I added on my answer.  
  
  ---
  
  ### Answer by username_2 on 2014-06-19. Score: 2
  
  When you are accessing a database "from a distance", it won't be called "localhost". Having the port in there is probably helpful, but you'll want to specify the DB server by its IP address.
  
  ```
  'localhost' => array(
    'server' => '(DB IP address):3307'
  )
  
  ```
  
  Also, be sure that your server database is allowing remote access. By default, most DBs will only allow access to their local files.
  
  > **Comments:**
  > **username_0**: If I set the 'server' attribute in the '*' array to 'localhost:3307', it works. I just need to add the port, which I'm doing here for localhost, but Craft isn't recognizing it.  
  > **username_2**: It works on your local machine, or on the remote server? "localhost" is supposed to mean local, which a remote server would not be.  
  > **username_0**: It works everywhere, 'localhost:3307' for local development and 'localhost' for the live site. I'm using an SSH tunnel to access the remote database.  
  > **username_2**: Ah, ok... that makes more sense.  
  
  ---
  
  ### Answer by username_3 on 2014-06-19. Score: 2
  
  This issue may be that your database name, prefix, password, etc are different on your local machine, than the ArcusTech server. If your local values don't match the values in the block defined with the asterisk, you won't be able to connect.
  
  Most local databases with tools like MAMP, use a default user and password like 'root'. Try to look into some of these values, or post more info about your local setup.
  
  > **Comments:**
  > **username_0**: I'm logging into the live database remotely - not dealing with dueling databases. In other words, if I add port 3307 to the '*' array, it works.  
  > **username_3**: Ah ok. I believe you would need the external IP to for where the MySQL DB is hosted. In this case, if you are using shared hosting on ArcusTech, this will not be your server IP. You might want to contact ArcusTech and ask how you might connect to MySQL with an external address.  I don't think you are able to refer to their databases by anything but localhost, without that ext IP. Which in this case, would cause Craft to look at your machine for localhost.  Hope this makes sense.  
  > **username_0**: I'm already successfully connecting to the database via SSH tunneling. For local development, I need to add the port, hence the added port under 'localhost' in my db config. Craft wouldn't look at my machine for localhost - it simply reads the value of the SERVER_NAME constant and compares that string to the string entered in db.php, which in this case is an exact match.  
  > **username_3**: So you have it all working now by adding the port?  
  > **username_0**: I wish. The issue was never the _address_, it's getting Craft to recognize the server name.  
  > **username_3**: So what I'm not understanding is, when you're on your machine, and craft sees that the server is localhost, it uses your config array specified for that. That config has 'server' set as 'localhost:3307', which on your machine, is localhost. It's trying to connect to YOUR_MACHINE:3307. It doesn't have an external server defined to get to your remote db. Localhost is relative to the box the code is running on. Does that make sense?  
  > **username_2**: He replied to my comment about that saying that he's using SSH tunneling to access the DB... so "localhost" would still work.  
  > **username_3**: I saw that, but from my understanding that doesn't work with ArcusTech? Might be best solved by contacting their support?  
  > **username_0**: No, no, no - Craft doesn't care about what does and does not constitute 'localhost'. It's not checking DNS, it's simply checking the server_name variable and comparing that string to the string specified as your server in the db config. Which is why this so puzzling.  
  
  ---
  
  ### Answer by username_4 on 2014-06-19. Score: 2
  
  If you're using MAMP you might also want to try using ".dev" or ".dv" for your array like so in your general.php config file:
  
  ```
  '.dev' => array(
       'devMode' => true,
  ),
  
  ```
  
  Versus using `localhost`.
  
  UPDATED Local / Live General.php file setup:
  
  ```
  return array(
      '*' => array(
          'cpTrigger' => 'admin',
          'omitScriptNameInUrls' => true,
          'defaultFolderPermissions' => 0755,
          'phpMaxMemoryLimit' => '1024M',
          'useCompressedJs' => true,
          'useEmailAsUsername' => true,
          'autominEnabled' => true,
          'autominCachingEnabled' => true,
          'autominMinifyEnabled' => true,
      ),
      '.dev' => array(
          'devMode' => true,
          'environmentVariables' => array(
              'siteUrl' => 'http://www.DOMAINNAME.dev/',
              'basePath' => 'LOCAL PATH',
              'autominPublicRoot' => basePath,
              'autominCachePath' => basePath.'cache',
              'autominCacheURL' => '/cache',
          )
      ),
      '.com' => array(
          'devMode' => false,
          'environmentVariables' => array(
              'siteUrl' => 'http://www.DOMAINANME.COM/',
              'basePath' => 'SERVER BASE PATH',
              'autominPublicRoot' => basePath,
              'autominCachePath' => basePath.'cache',
              'autominCacheURL' => '/cache',
          )
      )
  );
  
  ```
  
  > **Comments:**
  > **username_0**: Using WAMP - $_SERVER['SERVER_NAME'] contains "localhost", so nothing else will match.  
  > **username_4**: Check out my updated example. Are you setting up separate HOSTS in MAMP?  
  > **username_0**: Just saw your update - using tld's is just one approach, it really comes down to unique partial matches, which can look a number of different ways. As I stated, my local environment registers as 'localhost', so nothing else would work.  
  > **username_0**: wamp, I'm using wamp. Hosts aren't an issue, I'm accessing the local site at 'localhost'.  
  > **username_4**: I see. I use MAMP and that's just how I approach builds in different environments. Maybe you might consider updating your question with your exact setup so someone else can better understand and assist you.  
  > **username_0**: I didn't add the setup because it's unlikely to be relevant. My setup works as long as I indicate port 3307 in db.php. Craft is not recognizing my doing so for localhost.  
  
  ---
  
  ### Answer by username_5 on 2016-04-27. Score: 2
  
  `'localhost'` is simply not recognized when using as a domain-specific db config block. You have to use the general `'*'`-block when serving your site via `http://localhost/`
  
  
  ---
  
  ### Answer by username_6 on 2014-06-19. Score: 2
  
  Another option is to use named environments instead of using domain matching.
  
  in your `index.php` file, just set (changing 'development' to whatever you like):
  
  ```
  define('CRAFT_ENVIRONMENT', 'development');
  
  ```
  
  Then your environmental config array can use "development" as a key, instead of `localhost` or `.dev`
  
  > **Comments:**
  > **username_0**: Right, but if 'localhost' doesn't work, then assigning 'localhost' to an intermediate variable doesn't fix it. My initial setup attempted this and I bypassed it for troubleshooting.  
  > **username_6**: I don't follow. If you set the CRAFT_ENVIRONMENT constant, it bypasses any domain matching, so if you wanted to set that to 'localhost' you could, and it works. But generally, you'd set this something like development, production, or staging.  http://buildwithcraft.com/docs/php-constants#craft-environment  
  > **username_0**: Ah - I was using a script within index.php that dynamically assigns CRAFT_ENVIRONMENT based on the current environment. Statically assigning this variable seems to defeat the purpose of a multi-environment config, no?  
  > **username_6**: @username_0, I include an environment.php file at the top of my index.php that sets the `CRAFT_ENVIRONMENT` variable. This file stays out of source control, so, e.g. on my production server, I have an `environment.php` file that sets `CRAFT_ENVIRONMENT` to "production". Likewise for any other environment.  
  
  ---
  
  ### Answer by username_2 on 2014-06-19. Score: 1
  
  This boils down to being either one of two things...
  
  * A **database connection error**, or
  * An **environment detection error**.
  
  You seem very convinced that the database connection info is perfect, so let's explore the possibility of an environment detection error.
  
  Please conduct this test... Edit your **craft/config/general.php** file, and add this configuration:
  
  ```
  return array(
  
    '*' => array(),
  
    'localhost' => array(
      'devMode' => true
    )
  
  );
  
  ```
  
  Now login to your Craft control panel... **Do you see the yellow-striped "caution tape" at the top of your control panel?**
  
  If the answer is "yes", then your environment detection is working perfectly. Therefore, you have a database connection error.
  
  If the answer is "no", then you have an environment detection error. If this is the case, please answer this question:
  
  **Exactly what URL do you use to view your website on your local machine?**
  
  > **Comments:**
  > **username_0**: Hi username_2 - it's not a database connection error. You troubleshoot that by making the desired server address the default and seeing if it works, which it does. The issue is Craft correctly determining the environment. The exact URL for local development is "localhost", or more accurately, http://localhost  
  > **username_2**: Did you conduct the test with config/general.php? I've never heard of anyone else having trouble like this with their environment being detected.  
  > **username_0**: The database connection is precisely the same test that you're referring to, except instead of looking for yellow tape, I'm looking for a working database connection. The connection works perfectly fine if given the right server address. If the right address is under '*', it works. If it's under 'localhost', it doesn't. And I've never heard of anything like this either.  
  > **username_2**: It sounds like you haven't conducted the "yellow tape" test, and I encourage you to take 2 minutes and try it. Based on the results of that test, we can give you further guidance.  
  > **username_0**: Heh, you're persistent. I did it, no tape.  
  > **username_2**: Thanks. :)  Alright, so something is definitely screwed up with your environment detection... Whatever it is, it's not normal. At this point, the best advice anyone can give you is to contact support@buildwithcraft.com . Good luck, please let us know what the resolution ends up being!  
  
  ---
  
  