diff --git a/main/utils.c b/main/utils.c
index 6ce659c41f2caef92a19b92789af9a739ff3d0fe..dd0c3187a8493ee606b285cae8d5f9a8d77ac7b4 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -215,6 +215,8 @@ struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp)
 		hp->hp.h_addrtype = AF_INET;
 		hp->hp.h_addr_list = (void *) hp->buf;
 		hp->hp.h_addr = hp->buf + sizeof(void *);
+		/* For AF_INET, this will always be 4 */
+		hp->hp.h_length = 4;
 		if (inet_pton(AF_INET, host, hp->hp.h_addr) > 0)
 			return &hp->hp;
 		return NULL;