0

I installed Postgres 9.3 yesterday on Ubuntu 18.04 (using the Ubuntu package index). I need to add lines to the pg_hba.conf file to allow pgAdmin access on port 5432.

For example, I need to add a line in this format:

hostssl  database  user  address  auth-method  [auth-options]

My first question is what should I use for the the IP address in the "address" field. I am using pgAdmin on my local computer (Windows) to access my Ubuntu 18.04 server in the cloud, but I don't have a static IP address, so entering my IP address won't do. What IP address should I put in the address field for outside access from my local computer? It's not clear from the docs at https://www.postgresql.org/docs/11/auth-pg-hba-conf.html.

My second question is how do I indicate port 5432 in the line above? I believe that's the default listener port for Postgres, so doesn't it need to be specified in the line above?

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
RTC222
  • 2,025
  • 1
  • 20
  • 53
  • 1
    9.3 isn't supported anymore. It may be better to upgrade right away. – sticky bit May 22 '19 at 00:05
  • I just noticed that. The package index contains that one now. I'll upgrade, but I'll still have the same question. – RTC222 May 22 '19 at 00:09
  • 1
    If you want to allow all IP addresses you can use `0.0.0.0/0` (See ["Example 20.1."](https://www.postgresql.org/docs/11/auth-pg-hba-conf.html#EXAMPLE-PG-HBA.CONF). The port doesn't matter here. – sticky bit May 22 '19 at 00:12
  • Well, that should do it. Thanks. – RTC222 May 22 '19 at 00:13

1 Answers1

0

What you have to specify in pg_hba.conf is not an IP address, but a netmask: an IP address followed by a number between 0 and 32 that tells how many bits of the address are significant.

For example

12.23.34.99/24

matches all IP addresses between 12.23.34.0 and 12.23.34.255.

Find out in which range your possible IP addresses are and use that.

pg_hba.conf determines which authentication method is used for an incoming connection. It comes into play after the TCP connection to server port 5432 has been established.

To configure on which TCP port PostgreSQL should listen, edit postgresql.conf and restart PostgreSQL.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263