Error -- serendipity error: unable to connect to database -

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
mdwylde
Regular
Posts: 17
Joined: Wed Apr 20, 2016 10:23 pm

Error -- serendipity error: unable to connect to database -

Post by mdwylde » Thu Apr 21, 2016 8:15 pm

Hi --

We've have been having problems for the last few days with one of our Serendipity sites being down. It's been running for a number of years. The url is http://www.eartharchitecture.org/ The site is hosted on Bluehost.

I've checked with Bluehost and we are getting the following PHP error:
PHP Fatal error: Call to undefined function pg_connect() in /home1/raelsanf/public_html/eartharchitecture/serendipity/include/db/postgres.inc.php on line 56

Also - we are getting this error at the url address: New error -- serendipity error: unable to connect to database - exiting.

Can you please advise on how to correct this.

Thank you,
Marge d'Wylde

User avatar
yellowled
Regular
Posts: 7084
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany
Contact:

Re: Error -- serendipity error: unable to connect to databas

Post by yellowled » Thu Apr 21, 2016 9:40 pm

I assume the following information will be helpful:

* Which version of Serendipity is installed?
* Which version of PHP is the webserver running?
* Which version of PostgreSQL database is it trying to connect to?
* Have any of these changed recently, i.e. did you upgrade s9y, has the webserver been switched to a different PHP version etc.?

YL
amazon Wishlist - Serendipity-Podcast (German only, sorry)

mdwylde
Regular
Posts: 17
Joined: Wed Apr 20, 2016 10:23 pm

Re: Error -- serendipity error: unable to connect to databas

Post by mdwylde » Thu Apr 21, 2016 10:08 pm

Hi -- Here's what we have running:

Serendipity version: 1.5.1 (I'm looking at the "current version" file which I assume is it.) It looks like it was installed in 2012.
PHP: 5.4.43
PostgreSQL 8.4.20

My understanding is there have been no changes in the last few months from the user side. Clearly nothing has been updated in quite a while.

Thanks,
Marge

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Error -- serendipity error: unable to connect to databas

Post by Timbalu » Fri Apr 22, 2016 9:37 am

Apart from using a totally outdated Serendipity version, this most probably is this:

No (PHP) PostgreSQL extension (extension = pgsql.so) found. Please check your webserver installation or contact your systems administrator regarding this problem.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

mdwylde
Regular
Posts: 17
Joined: Wed Apr 20, 2016 10:23 pm

Re: Error -- serendipity error: unable to connect to databas

Post by mdwylde » Mon Apr 25, 2016 10:40 pm

OK -- Thanks I will check that. And yes, I agree they need an update once we get this fixed.

Warm regards,
Marge

mdwylde
Regular
Posts: 17
Joined: Wed Apr 20, 2016 10:23 pm

Re: Error -- serendipity error: unable to connect to databas

Post by mdwylde » Tue Apr 26, 2016 5:09 am

Hi --

I've contacted the server administrator per your recommendation:

It appears that the database software is up and running:

PDO
These PDO packages are installed and running:
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql

They also provided this information:
/home1/raelsanf/public_html/eartharchitecture/serendipity/include/db/postgres.inc.php

line 64, is simply a close tag on your site, but the lines before show dbname, user, pass, host, and haven't been filled out. Looks to be an issue with your site config/developer issue.

They tried a database restore but that didn't change anything. We're still getting the following error:
serendipity error: unable to connect to database - exiting.

Can you please make some further suggestions.

Thanks,
Marge

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Error -- serendipity error: unable to connect to databas

Post by Timbalu » Tue Apr 26, 2016 9:38 am

I am not really able to debug this outdated version file with you.
Please check your blog roots serendipity_config_local.inc.php file. The db credentials in there must fit to a correct login to postgres. Check this up!

Best would be to have another independent test file using this same credentials to be sure about this.
(See http://php.net/manual/en/function.pg-connect.php different example(s) file. These connect examples should at least have a die() at the end, to properly return not being usable though.

Code: Select all

pg_connect("...") or die('connection failed');
Take the one thats suites your credentials at best.)

If you can't find anything that takes you away, finding the real cause of this issue, you might want to save this postgres.inc.php file to postgres.inc.php.old and upload this new raw file to that directory. Just save it by browser and upload that downloaded file to your server. Maybe that helps.
https://raw.githubusercontent.com/s9y/S ... es.inc.php

If that all does not help, I am not sure about how to proceed. Ask your ISP to help you and/or find out what they might have changed. Updating Serendpity at whole is a little risky without having access to the database with your current credentials.

If you ask your ISP, ask them to check the pg_hba.conf file to allow (trust) the host, set in $serendipity['dbHost'].
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

User avatar
onli
Regular
Posts: 2266
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Error -- serendipity error: unable to connect to databas

Post by onli » Tue Apr 26, 2016 11:12 am

Timbalu wrote:Please check your blog roots serendipity_config_local.inc.php file
That is an important thing to do, please make sure the right credentials are set here. But it is most likely not the issue. See https://github.com/s9y/Serendipity/blob ... c.php#L267 – the error message "Could not connect - exiting" (DATABASE_ERROR) is triggered whenever the connection did not work. Since your PHP error log shows that pg_connect() was undefined, that can't ever work even with correct credentials. pg_connect is the function used with the postgres-database layer, see https://github.com/s9y/Serendipity/blob ... nc.php#L47.

It must be highly frustrating to deal with a hoster who says it is a configuration issue, but I'm 99% certain the fault is on the server and thus likely with the hoster. Something there killed your PHP installation, the postgres-module can no longer be loaded.

It is possible that this is not directly the hoster's fault. It could be the result of a hack, PHP 5.4.43 is not a secure version – neither is s9y 1.5.1 nor Postgres 8.4. It could also be the result of a necessary operating system upgrade. But something broke on the server, the error message leaves no doubt.

mdwylde
Regular
Posts: 17
Joined: Wed Apr 20, 2016 10:23 pm

Re: Error -- serendipity error: unable to connect to databas

Post by mdwylde » Tue Apr 26, 2016 3:19 pm

Hi --

OK, I'll check these today but I agree with you that there may have been an upgrade of the server software, or a hack. However the directories are not showing any malware activity.

How risky is it to do an upgrade first to see if that fixes it?

Thank you,
Marge

User avatar
onli
Regular
Posts: 2266
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Error -- serendipity error: unable to connect to databas

Post by onli » Tue Apr 26, 2016 3:28 pm

Have a proper backup of both files and database and then an upgrade is no danger at all for s9y. But you need a newer php version for that, which could mean you need to upgrade your server operating system. That depends on which system that is exactly.

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Error -- serendipity error: unable to connect to databas

Post by Timbalu » Tue Apr 26, 2016 3:38 pm

onli wrote:But you need a newer php version for that, which could mean you need to upgrade your server operating system.
This is not true.
PHP is at: 5.4.43, which is near the last state of Debian Wheezy (for example), as far as I remember. And would be OK even with upcoming 2.1.
mdwylde wrote:How risky is it to do an upgrade first to see if that fixes it?
I would really recommend to not do a Serendipity upgrade bevor having full access again!! Better check the things mentioned in the last post.
And this, since there are a lot of upgrade tasks need to be done and better have a Spartacus update for plugins first.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

mdwylde
Regular
Posts: 17
Joined: Wed Apr 20, 2016 10:23 pm

Re: Error -- serendipity error: unable to connect to databas

Post by mdwylde » Tue Apr 26, 2016 5:13 pm

Very good. I'll check and see if we can fix first.

Thank you,
Marge

User avatar
onli
Regular
Posts: 2266
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Error -- serendipity error: unable to connect to databas

Post by onli » Tue Apr 26, 2016 5:31 pm

Timbalu wrote:
onli wrote:But you need a newer php version for that, which could mean you need to upgrade your server operating system.
This is not true.
PHP is at: 5.4.43, which is near the last state of Debian Wheezy (for example), as far as I remember. And would be OK even with upcoming 2.1.
You're right. Debian oldstable is Wheezy and that is still on PHP 5.4, despite that version being no longer supported by the php project itself (where I looked).

S9y itself will still run on php 5.4 (I forgot that the changes I wanted to make that broke PHP 5.4 were stopped), but 2.1 might break that when we make the changes for php 7. We'll see. Not relevant here anyway.

Still: To upgrade the PHP version should be a good way to fix the initial problem, and to make sure php5-pgsql is installed.

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Error -- serendipity error: unable to connect to databas

Post by Timbalu » Tue Apr 26, 2016 5:49 pm

onli wrote:make sure php5-pgsql is installed
This was already asked and answered with yes by the ISP!

Is this thread getting a "too many cooks spoil the broth" confusion? :)
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

User avatar
onli
Regular
Posts: 2266
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Error -- serendipity error: unable to connect to databas

Post by onli » Tue Apr 26, 2016 6:17 pm

It doesn't matter what the hoster is saying. If that function can't be found that modul is either not installed or not loaded.

Post Reply