Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got a clean instance of CentOS and a clean instance of RHEL 6.3 - I've tried to installed Moodle on both.

Error: Database connection failed

It is possible that the database is overloaded or otherwise not running properly.

The site administrator should also check that the database details have been correctly specified in config.php

The database does work - I've tried it from a shell on the box. I've tried with a remote database, and with a local database.

I've tried to remove the config.php and clear the database, and allow moodle to create run it's fresh install script, and again, I have the same problem.

The stange thing is, that I have RHEL 5.x and 6.x boxes that are running moodle instances, but I never had a problem installing them, so I never really looked closly at the stack. What is worrying me, is that these failures are occurring on my new system images - Systems that have been updated to the latest available packages in the repo in the last few weeks.

Has anyone else come across a similar problem?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I indeed have exactly the same problem; note that this is the first time I install moodle with postgres. The question is clearly one in the interoperability of php and pgsql, as is evident from the http error log: ( I have replaced "localhost" with "127.0.0.1")

PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Permission denied\n\tIs the server running on host "127.0.0.1" and accepting\n\tTCP/IP connections on port 5432? in /var/www/html/moodle/lib/dml/pgsql_native_moodle_database.php on line 163

Looking at the pg logs,I notice that no connection gets through. I have turned off the firewall, so that is not that either.

I finnaly thought of selinux--that is usually the problem. A little bit of googling shows that

setsebool -P httpd_can_network_connect 1

solves this problem.

share|improve this answer
    
I will take a look at this, thanks for the tip - I did finally get it working, but the problem looked more like it was developer error - But I will make a note of this –  Mister IT Guru Jan 16 '13 at 13:40
    
I've accepted this because the difference between the test rig and the production rig was indeed SE linux –  Mister IT Guru Jan 17 '13 at 12:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.