diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 7e3104389c8436175a2a72ab5c778414a28b27a1..c6475c5180f694f496a6f4b02a918530af53dc9f 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -28119,11 +28119,11 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
 		ast_string_field_set(peer, tohost, srvlookup);
 
 		if (global_dynamic_exclude_static) {
-			int err = 0;
+			int ha_error = 0;
 			sip_cfg.contact_ha = ast_append_ha("deny", ast_sockaddr_stringify_addr(&peer->addr), 
-							sip_cfg.contact_ha, &err);
-			if (err) {
-				ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value);
+							sip_cfg.contact_ha, &ha_error);
+			if (ha_error) {
+				ast_log(LOG_ERROR, "Bad or unresolved host/IP entry in configuration for peer %s, cannot add to contact ACL\n", peer->name);
 			}
 		}
 	} else if (peer->dnsmgr && !peer->host_dynamic) {
diff --git a/main/acl.c b/main/acl.c
index f3795c95a07b55afdd41c76a5a0c871d74d0e191..69713bbd8de0ccb720d7bbb85e26427b15bb3f17 100644
--- a/main/acl.c
+++ b/main/acl.c
@@ -408,6 +408,9 @@ struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha
 	}
 
 	if (!(ha = ast_calloc(1, sizeof(*ha)))) {
+		if (error) {
+			*error = 1;
+		}
 		return ret;
 	}