This is the correspondig Github issue: Fleet server tries elasticsearch connection via localhost instead of configured elasticsearch url. · Issue #4873 · elastic/elastic-agent · GitHub
Hi,
Can you check the elasticsearch output configurations in Fleet settings? Do you see localhost anywhere?
There was no localhost. I checked everything multiple times and found the issue in my peer cert bundle. The intermediate CA was in Binary format while Root and Peer were PEM formatted.