Why is hostname resolving well for some commands but not for other commands?

I use check_http and check_tcp Nagios plugins to check some endpoints from a RHEL 8.10 box.

My problem is both return this for some domain names:

Name or service not known

Instead, well-known commands like curl, wget, ping, nc, nslookup, dig, host and getent hosts do not show any issue when solving those same host names.

I thought these Nagios plugins somehow use the wrong DNS server from /etc/resolv.conf and then I tried to export a RES_OPTIONS environment variable in order to force a DNS server, according to resolv.conf(5) manual pages, but it does not work.

Does anyone have any idea what is happening here?