0

I need to connet a remote PostgreSQL database in Codeigniter 3 web site. The database configuration in CI 3 is the following:

$db['postgres'] = array(
    'dsn'   => '',
    'hostname' => 'simbywire.org',
    'username' => 'postgres',
    'password' => 'xxxxxxx',
    'database' => 'aeroclub',
    'dbdriver' => 'postgre',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => TRUE,
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE,
    'port'   => 5432,
);

I have enabled the PHP modules PGSQL and PDO_PGSQL

I get the following error trying to connect to the db:

Message: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host "simbywire.org" (176.58.111.4) and accepting TCP/IP connections on port 5432?
Filename: postgre/postgre_driver.php

If I try to connect to the remote server using pgAdmin I can succesfully get into it...so I'm sure about the server name, username and password. pgAdmin screenshot

Any help or idea to fix the issue? Thanks a lot

EDIT: The following command on remote PostgreSQL server

sudo netstat -ltnp | grep postgres

produced the following result:

tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      756/postgres
tcp        0      0 127.0.0.1:5433          0.0.0.0:*               LISTEN      754/postgres
tcp        0      0 127.0.0.1:5434          0.0.0.0:*               LISTEN      755/postgres
tcp6       0      0 :::5432                 :::*                    LISTEN      756/postgres
Federico
  • 319
  • 2
  • 14
  • Check if the postmaster is accepting TCP/IP connections, see: https://stackoverflow.com/questions/20825734/postgresql-connection-refused-check-that-the-hostname-and-port-are-correct-an – Vickel Sep 13 '21 at 17:05
  • Thanks a lot for feedback Vickel. In the first post the result of TCP/IP query – Federico Sep 13 '21 at 17:56
  • The server seems to be configured to accept TCP/IP connection...I can connect with it using IOS app...but not able to get connected using PHP. Honestly I have no idea what could be the issue – Federico Sep 14 '21 at 15:23

0 Answers0