coverity: 37468: confirm gethostname worked
diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c
index 38e03c8..2e6d09b 100644
--- a/lib/roles/http/server/server.c
+++ b/lib/roles/http/server/server.c
@@ -3071,8 +3071,10 @@
 		return;
 #if !defined(LWS_PLAT_FREERTOS)
 	/* find canonical hostname */
-	gethostname((char *)context->canonical_hostname,
-		    sizeof(context->canonical_hostname) - 1);
+	if (gethostname((char *)context->canonical_hostname,
+		        sizeof(context->canonical_hostname) - 1))
+		lws_strncpy((char *)context->canonical_hostname, "unknown",
+			    sizeof(context->canonical_hostname));
 
 	lwsl_info(" canonical_hostname = %s\n", context->canonical_hostname);
 #else