I'm not really sure if this is the right place to post this but I happened across a peculiar behaviour yesterday.
Historically, when debugging locally, our application's first connection to a given database (foo.local
) has taken quite a long time (i.e. ~5s).
I discovered yesterday that changing the Hosts file from this:
127.0.0.1 localhost
127.0.0.1 foo.local
to
127.0.0.1 localhost foo.local
Has completely removed this delay - now our application initialises almost instantly.
The issue appears to have been some failed DNS lookup, but I can't really figure out exactly what was happening. Was hoping someone could shed some light on this.
I know that postgres has log_hostname
which (I believe) tries to perform a reverse lookup to identify the hostname, and to my knowledge this is not supported in the Hosts file.
However this connection delay occurred regardless of whether log_hostname
was on or off.
¯_(ツ)_/¯
Not an urgent question since the issue has more or less been resolved, but my curiosity has the better of me. If anyone has any ideas I'd be very appreciative!
Extra info:
Postgres: PostgreSQL 14.6 on aarch64-apple-darwin20.6.0, compiled by Apple clang version 12.0.5 (clang-1205.0.22.9), 64-bit
Npgsql: 6.0.8 (but also reproduced in 7.0.6)
Platform: Mac Sonoma 14.1.1
foo.local
. Apologies for not stating that.