Connecting to a remote PostgreSQL server

February


  1. Preparatory measures

    Create the user you want to connect as (which is generally not the database owner, see example), and the database you want to connect to:

    [Note]Note

    Make sure that the script that fills the database grant appropriate access to your connecting user, as in

    GRANT SELECT, INSERT, UPDATE, DELETE ON Session TO lu_webadmin;

  2. Set a record in /etc/postgresql/8.3/main/pg_hba.conf to allow access by this user to this database:

    hostssl userlogger  lu_webadmin,lu_reader                   10.0.2.13/32      md5
    	

    [Note]Note

    Be careful: entries in pg_hba.conf are hit-or-miss: once the conntype/username/database/host matches a line, that line determines whether your connection succeeds. No other lines are tried.

  3. reload the PostgreSQL config

    A reload is enough:

  4. Try to connect from the remote host: