Has anyone successfully configured a WordPress app using the Heroku Postgres add-on? I’ve inherited a WordPress app that’s currently running on Heroku, but not using the Heroku Postgres add-on.
I’m trying to create a staging instance of the app and keep receiving, “Error establishing a database connection”.
I’m using the PG4WP plugin and spawned a heroku-postgresql:dev instance.
My DATABASE_URL config var is of the following format:
postgres://xxxxxx:yyyyyy@zzzzzzz.compute-1.amazonaws.com:5432/xxxxxxxxx
My wp-config is below:
if (isset($_SERVER["DATABASE_URL"])) {
$db = parse_url($_SERVER["DATABASE_URL"]);
define("DB_NAME", trim($db["path"],"/"));
define("DB_USER", $db["user"]);
define("DB_PASSWORD", $db["pass"]);
define("DB_HOST", $db["host"]);
}
else {
die("Your heroku DATABASE_URL does not appear to be correctly specified.");
}
The wordpress-heroku fork of WordPress solved my problem.
It worked out-of-the-box and if you are planning to use WordPress on Heroku, I would definitely recommend it.
Unfortunately, I still don’t know what I was doing incorrectly the first time around.