diff --git a/doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst b/doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst
index 9824b58ef..cce03bc0c 100644
--- a/doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst
+++ b/doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst
@@ -511,6 +511,17 @@ overview of their function and contents.
 
          BB_HASHSERVE_UPSTREAM = "hashserv.yoctoproject.org:8686"
 
+   :term:`BB_HASHSERVE_UPSTREAM_TIMEOUT`
+      Specifies the duration (in seconds) for which BitBake waits for the first
+      response from the upstream Hash Equivalence server (specified by
+      :term:`BB_HASHSERVE_UPSTREAM`).
+
+      This variable prevents BitBake from waiting too long for an unavailable server.
+      If the time expires, the upstream Hash Equivalence server will be skipped for
+      the build.
+
+      The default value is "10" (seconds).
+
    :term:`BB_INVALIDCONF`
       Used in combination with the ``ConfigParsed`` event to trigger
       re-parsing the base metadata (i.e. all the recipes). The
diff --git a/lib/bb/asyncrpc/client.py b/lib/bb/asyncrpc/client.py
index 17b72033b..5e2505494 100644
--- a/lib/bb/asyncrpc/client.py
+++ b/lib/bb/asyncrpc/client.py
@@ -199,8 +199,8 @@ class AsyncClient(object):
         self.check_invoke_error(result)
         return result
 
-    async def ping(self):
-        return await self.invoke({"ping": {}})
+    async def ping(self, timeout=None):
+        return await asyncio.wait_for(self.invoke({"ping": {}}), timeout)
 
     async def __aenter__(self):
         return self
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 4b6ba3196..c7ced1e37 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -342,7 +342,7 @@ according to https://docs.yoctoproject.org/dev-manual/hashequivserver.html""".fo
                 if upstream:
                     try:
                         with hashserv.create_client(upstream) as client:
-                            client.ping()
+                            client.ping(int(self.data.getVar("BB_HASHSERVE_UPSTREAM_TIMEOUT")) or 10)
                     except ImportError as e:
                         bb.fatal(""""Unable to use hash equivalence server at '%s' due to missing or incorrect python module:
 %s
@@ -352,7 +352,7 @@ Please install the needed module on the build host, or use an environment contai
  - or set up pip venv
 You can also remove the BB_HASHSERVE_UPSTREAM setting, but this may result in significantly longer build times as bitbake will be unable to reuse prebuilt sstate artefacts."""
                                  % (upstream, repr(e)))
-                    except ConnectionError as e:
+                    except (ConnectionError, TimeoutError) as e:
                         bb.warn("Unable to connect to hash equivalence server at '%s', please correct or remove BB_HASHSERVE_UPSTREAM:\n%s"
                                  % (upstream, repr(e)))
                         upstream = None
