postgresql: Error connecting to DB

BASE-user
DAW
2008-11-26
2013-06-03
  • DAW
    DAW
    2008-11-26

    Having trouble getting started w/ Base.

    In base_conf.php:
    $BASE_urlpath = "/base";
    $DBlib_path = "/usr/share/php/adodb";
    $DBtype = "postgres";
    ...
    $alert_dbname   = "snort";
    $alert_host     = "127.0.0.1";
    $alert_port     = "5432";
    $alert_user     = "snort";
    $alert_password = "snort";

    But when I try to access: "http://127.0.0.1/base/base_main.php", I get:

    Error (p)connecting to DB : snort@127.0.0.1:5432
    Check the DB connection variables in base_conf.php
                   = $alert_dbname   : MySQL database name where the alerts are stored
                   = $alert_host     : host where the database is stored
                   = $alert_port     : port where the database is stored
                   = $alert_user     : username into the database
                   = $alert_password : password for the username            
    Database ERROR:Database connection failed

    I know I have the correct parameters, I can
       "$ psql -h localhost -U snort snort"
    with no problem.

    I don't know what is wrong. Can any body help?
    Thanks!

     
    • Daniel Requena
      Daniel Requena
      2008-12-05

      Hey,

         I'm having the same problem here. My situation is: I have Snort+Barnyard installed and it's working fine...
         To have sure it was not a postgresql problem I edited the /etc/postgresql/8.1/main/pg_hba.conf like this:

      local    snort    snort    md5
      local    snort    snort    password
      host    snort    snort    10.0.0.214/32 password
      host    snort    snort    127.0.0.1/32 password

         But, still not worked. So I tried to get more information about Posgresql logon by editing the file /etc/postgresql/8.1/main/postgresql.conf like this:

      log_connections = on

         When I start Barnyard or connect just like you said on your post a new line appears on LOG

      2008-12-05 10:14:57 BRST LOG:  connection received: host=[local]
      2008-12-05 10:14:58 BRST LOG:  connection received: host=[local]
      2008-12-05 10:14:58 BRST LOG:  connection authorized: user=snort database=snort

         But there is no activity at all when base is running...I suppose that the php is not even trying to connect on DB.
         I double check the base_conf file, my $DBlib_path variable is correct. Can somebody help please?
         Thanks.

       
      • Hello requena,

        are you sure you have a line

        $DBtype = 'postgres';

        in your base_conf.php?

        You are right:

        A "LOG:  connection authorized:..." appears, as soon as BASE
        tries to connect to the database, i.e. when the first query
        is about to be launched (click at "unique" or "listing").
        And a second line also appears, provided that you use
        the archive database.

        Bye, bye

        Juergen

         
    • I too have this problem, it is as iff base is trying to make a mysql connection to postgres.

       
      • Hello Scott,

        and you are absolutely sure, that in base_conf.php there is a line:

        $DBtype = 'postgres';

        If so, try and increase the logging with postgresql:

        Set "log_connections = on" in postgresql.conf,
        maybe also log_hostname and log_line_prefix, accordingly.

        There should be a line like:

        LOG:  connection authorized: user=snort database=snort

        If not, have a look at the apache logs (access log, error log).

        And maybe, you could observe the connection attempt by the
        web server by means of a sniffer (tcpdump, tshark/wireshark).

        Bye, bye

        Juergen

         
    • Kevin Johnson
      Kevin Johnson
      2008-12-08

      I will check it out this evening and see what I can find.
      Kevin

       
    • Hello DAW,

      What do the logs say?

      Set "log_connections = on" in postgresql.conf,
      maybe also log_hostname and log_line_prefix, accordingly.

      There should be a line like:

      LOG:  connection authorized: user=snort database=snort

      Bye, bye

      Juergen

       
    • Michael
      Michael
      2009-01-05

      I had this same problem...

      I don't know what the problem was, but here's what fixed it for me; it was a wonky config file (base_conf.php).

      I copied over a fresh version of the base_conf.php.dist from the source to /var/www/html/base_conf.php and manually edited the configuration.

      If you're familiar enough with your setup and this config, just start fresh and manually edit it, otherwise get it out of the way (mv base_conf.php base_conf.php.bak, e.g.) and run the gui setup again from your browser.

      I have no idea how/why mine got silly in the first-place, but this fixed it...

      Hope this helps!
      Cheers!
      Michael

       
    • b0e
      b0e
      2009-04-02

      Same problem here. Nothing in the postgresql/webserver/php logs.
      $DBtype = 'postgres';  is set
      Just as BASE never tries to connect.
      Even wireshark doesn't see anything...

      Michael's solution doesn't work for me!

      Any hints for me?

      Kind regards, boe

       
    • Bert Haanstra
      Bert Haanstra
      2009-04-06

      I had the same issue,

      Snort is able to log to pgsql, but base not.

      Because base is an php website, i starting to check my php rpm`s and find out that i was missing php-pgsql.

      I installed this whiff " yum install php-pgsql"

      After this, base is able to logon.

      reguards,

      Isog