I spent some time on the following problem. It's more an explanation 'why', not so much a solution. I'm using CakePHP 1.3.4 and typically switch database configuration based on the `env('HTTP_HOST')` variable. In this specific case I diverted from my regular setup in which `$this->default` is the `localhost` database configuration and `$this->live` is the stage database configuration. Instead I switched those two. As I was calling `cake schema generate` I received errors telling me things like `PHP Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in` and `Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in` Clearly there was no database connection. I didn't detect anything weird when calling the site on `http://localhost`, it switched nicely based on the `env('HTTP_HOST')` variable. After some experimenting I discovered that having my `localhost` database config as the default config solved the problem. That pointed me to the fact that `env('HTTP_HOST')` is not present when calling `bake`. It's a server variable, and when running from the command line, the server doesn't play a role. By assigning the localhost config to the `$this->default` variable I can easily bypass the problem. Though I foresee a small inconvenience when working with multiple developers, committing to the same repository, that all have their own localhost test config.