Skip to content

Error Establishing Database Connection (a possible solution to this) #66

@tden012

Description

@tden012

I tried using the nginx recipe of this cookbook today on an ubuntu 14.04 machine and it all installed beautifully. BUT...

When I tried to run Wordpress nothing happened. This turned out to be an easy fix - nginx wasn't running, so I had to type:

sudo service nginx start

This started nginx, even though there was no output from the console.

The second problem I ran into was that on accessing the main web page, I got the error: "Error Establishing Database Connection"

Took me a while to figure out - and after some googling, I came across the cause. Turns out that Wordpress doesn't like the database host being referred to as 'localhost'. Instead, you have to use '127.0.0.1'.

Changing this is quite easy. You have to do this from within your cookbook:

If you are using your own cookbook, you can set the host in recipes/default.rb like this:

node.default['wordpress']['db']['host']  = "127.0.0.1"

or alternatively, you can set it in attributes/default.rb like this (useful if you follow the wrapper cookbook pattern):

default['wordpress']['db']['host'] = "127.0.0.1"

This allows everything to work as expected. But I'm curious - does anyone know why using 'localhost' doesn't work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions