Re: Does PostgreSQL listen_addresses='*' Dynamically Detect New Interfaces - Mailing list pgsql-admin

From Pratik Pandit
Subject Re: Does PostgreSQL listen_addresses='*' Dynamically Detect New Interfaces
Date
Msg-id CAFchsDXPDTf_4FQi2Q2sfrQ-E=uoT4Xz5wYZZ7jJmjCK61uSMw@mail.gmail.com
Whole thread Raw
In response to Does PostgreSQL listen_addresses='*' Dynamically Detect New Interfaces  (Stelios Malathouras <s.malathouras@deltasoftsolutions.net>)
List pgsql-admin

Hi Stelios,

Yes, this behavior is typical for PostgreSQL when listen_addresses is set to '*'. When PostgreSQL is configured to listen on all available network interfaces (via listen_addresses = '*'), it dynamically detects new interfaces and IP addresses without requiring a restart or service reload. So, as long as listen_addresses is '*' and the necessary network interfaces are configured correctly in the OS, PostgreSQL should continue functioning as expected without requiring a restart.

Why it is safe (under normal conditions) : -

  1. OS handles the interfaces: PostgreSQL trusts the OS to expose valid network interfaces. If the OS assigns a new IP, PostgreSQL bound to '*' can accept connections immediately — no corruption or instability risks.

  2. No restart required: As you observed, PostgreSQL doesn't need to rebind or restart because it's already listening on the wildcard interface (0.0.0.0 or :: for IPv6).

  3. Used in production setups: Many production systems with HA setups (e.g., floating IPs or VIPs) rely on this behavior during failover


Thanks,
Pratik Pandit

On Mon, May 5, 2025 at 2:26 PM Stelios Malathouras <s.malathouras@deltasoftsolutions.net> wrote:
Hi,

We've scheduled for an IP change for one of our dedicated PostgreSQL servers, running on version 13.8.
Our local tests, with listen_addresses = '*',  show that the postgres listener accepts connections immediately to the new IP.
The same behavior is observed when adding a new network interface.  Postgres accepts connections to the new network interface (and IP) immediately without requiring a restart.

Is it safe to assume this is the default behaviour ? How does the instance detect new interfaces and their IP(s) and begin listening on them without needing a service reload or restart?  

Thanks,

Stelios

 

pgsql-admin by date:

Previous
From: Stelios Malathouras
Date:
Subject: Does PostgreSQL listen_addresses='*' Dynamically Detect New Interfaces
Next
From: Tom Lane
Date:
Subject: Re: Does PostgreSQL listen_addresses='*' Dynamically Detect New Interfaces