LKBEN11151: Howto connect to postgres from the network


This article has not been checked!

LKB | Created: 02/04/2020 | Version: 0 | Language: EN | Rating: 0 | Outdated: False | Marked for deletion: False

Author: Wim Peeters - Keskon GmbH & Co. KG


Symptom

You want to connect to your postgresql server but you do not get access to the system although the server is listening on port 5432.

Cause

none

Solution

In the case your server is listening to the default port and you do not get access, you will have to make changes to your pg_hba.conf file.

On debain you can find this file in a postgres dependent path. e.g.

/etc/postgresql/8.3/main/

For information about how to make postgres listen on your network card, which is not the default, you can search in the knowledge base on "Howto make shure postgres will listen on the network".

In your pg_hba.conf file you will find the following:

...
# "local" is for Unix domain socket connections only
local   all         all                               ident sameuser
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5
...


I you want to listen from a full class network 192.168.123.0 with subnet mask 255.255.255.0 you can add the following line:

host    all         all         192.168.123.0/24        trust

If you restart your postgres server, you will be able to connect from the network.

Restarting can be done with:

invoke-rc.d postgresql-8.3 restart

About the Author

Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux in different European countries and different European languages. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform where he is one of the most important contributors and the main developer.

Disclaimer:

The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!