What does h_error=4 mean???

Jim Reid jim at rfc1035.com
Wed Jul 10 11:43:42 UTC 2002


    >> I have intermittent errors with some domains that result in
    >> h_error=4...

    >> Some domains result in h_error=4 which according to the man
    >> page for gethostbyname means NO_ADDRESS 

Are you *sure* about that? According to <netdb.h> on my BSD systems,
when h_error is 4 it means NO_DATA: the name exists but has no
record(s) of the desired type. In other words, the name might exist as
an MX record (say) but doesn't have an A or AAAA record. Remember too
that the gethostby{name,addr}() routines can use a bunch of lookup
mechanisms, sometimes in any combination: ie /etc/hosts, DNS, NIS,
NIS+, funky name cache daemons like nscd, and so on. If anything other
than DNS is involved, all bets are off. Though how they'd know or
care about record types is beyond me.

BTW, the BSD man page for gethostbyname says h_error can have the
following values: NETDB_INTERNAL, HOST_NOT_FOUND, TRY_AGAIN,
NO_RECOVERY and NO_DATA. There's no mention of NO_ADDRESS at all.
However there's a #define in <netdb.h>:

/*
 * Error return codes from gethostbyname() and gethostbyaddr()
 * (left in extern int h_errno).   
 */

#define NETDB_INTERNAL  -1      /* see errno */
#define NETDB_SUCCESS   0       /* no problem */
#define HOST_NOT_FOUND  1	/* Authoritative Answer Host not found */
#define TRY_AGAIN       2	/* Non-Authoritive Host not found, or SERVERFAIL */
#define NO_RECOVERY     3	/* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
#define NO_DATA         4	/* Valid name, no data record of requested type */
#define NO_ADDRESS      NO_DATA         /* no address, look for MX record */

Perhaps this explains the confusion?


More information about the bind-users mailing list