0

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

4
  • Do you know which hostname your application attempts to use? If you do, why did you choose not to disclose this information?
    – mustaccio
    Nov 14 at 1:03
  • @mustaccio If your question is which hostname is in my connectionstring, in this example it would be foo.local. Apologies for not stating that.
    – Jmase
    Nov 14 at 1:26
  • This looks like fundamentally a DNS question. I doubt dba is the best forum for it (although I would be interested in knowing the answer)
    – jjanes
    Nov 14 at 17:37
  • @jjanes I think you're probably right - I'd originally thought this might've been some unique behaviour of postgres hence why I posted it here. I'll comment if I end up finding out the answer.
    – Jmase
    Nov 16 at 0:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.