Support / KnowledgeBase

 
Search the KnowledgeBase Search

How do I enable remote access to my PostgreSQL server?

  • Applies to: All (dv)

  • Difficulty: Medium

  • Time needed: 10 minutes

  • Tools needed: SSH, root or sudo access, vi knowledge, PostgreSQL installed

 
  • Applies to: All (dv)
    • Difficulty: Medium
    • Time Needed: 10
    • Tools Required: SSH, root or sudo access, vi knowledge, PostgreSQL installed

Overview

The (dv) Dedicated-Virtual Server does not come with PostgreSQL pre-installed. The default configuration of PostgreSQL does not allow incoming connections from external machines.

Requirements

Before you start, this article has the following dependencies:

READ ME FIRST

The publishing of this information does not imply support of this article. This article is provided solely as a courtesy to our customers. Please take a moment to review the Statement of Support.

External PostgreSQL connections

1. To be able to reach the server remotely you have to add the following line into the file: /var/lib/pgsql/data/postgresql.conf:

listen_addresses = '*'

2. PostgreSQL, by default, refuses all connections it receives from any remote address. You have to relax these rules by adding this line to /var/lib/pgsql/data/pg_hba.conf:

host all all  0.0.0.0/0 md5

This is an access control rule that lets anyone login from any address if a valid password is provided (the md5 keyword). You can use your network/mask instead of 0.0.0.0/0 to only allow access from certain IP addresses.

3. When you have applied these modifications to your configuration files, you will need to restart the PostgreSQL server.

/etc/init.d/postgresql start

Now, you will be able to login to your server remotely.


User Comments

No visitor comments posted. Post a comment
Fields marked with an asterisk(*) are required. Comment on this article
Fill out the form below if you would like to comment on this article.
 
 
 

(code is not case-sensitive)
 
Submit
 
 

Continue