When the number of connection options gets too much, you may want to think about using a connection service file.
The connection service file allows you to give a single name to a set of connection parameters. This can be accessed centrally to avoid the need for individual users to know the host and port of the database, and is more resistant to future change.
First, create a file named
pg_service.conf with the following contents:
[dbservice1] host=postgres1 port=5432 dbname=postgres
You can then either copy it into place at
/etc/pg_service.conf or another agreed central location. You can then set the environment variable
PGSYSCONFDIR to that directory location.
Now, you can then specify a connection ...