Your question asks how to enable network connections to your PostgreSQL cluster. You can use either method you describe, they are roughly equivalent for most cases. Changing
listen_addresses requires a server restart, so plan accordingly.
The one consideration is if your host is multi-homed, that is, connected to multiple networks. If it is, and you don’t want to expose PostgreSQL to all of the networks, then specify the interface IPs of the networks you want to bind PostgreSQL to, and leave out the ones you don’t.
The special address ‘*’ tells PostgreSQL to bind to all available addresses. In most cases, that is just the server’s single IP. (And
localhost but that is less important.)
If you have a firewall enabled then you will also need to allow connections through the firewall.
There are serious security implications to enabling network connections. NEVER expose PostgreSQL to the unfiltered public Internet. Your database will be hacked and turned into a cryptocurrency miner if that happens. Use a firewall to limit access to just the replication clients.
The DigitalOcean article doesn’t mention it, so it might be in there by default on Ubuntu, but you need an entry in
pg_hba.conf telling PostgreSQL how to authenticate network clients. If you get authentication errors in the PostgreSQL log when the replication clients try to connect then that is likely the issue.