{"record":{"id":"58aca37bb279d53f","repo":"apache/hadoop","slug":"could-not-connect-to-history-server","errorCode":null,"errorMessage":"Could not connect to History server.","messagePattern":"Could not connect to History server\\.","errorType":"exception","errorClass":"YarnRuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ClientCache.java","lineNumber":63,"sourceCode":"\n  private Map<JobID, ClientServiceDelegate> cache = \n      new HashMap<JobID, ClientServiceDelegate>();\n\n  private MRClientProtocol hsProxy;\n\n  public ClientCache(Configuration conf, ResourceMgrDelegate rm) {\n    this.conf = conf;\n    this.rm = rm;\n  }\n\n  //TODO: evict from the cache on some threshold\n  public synchronized ClientServiceDelegate getClient(JobID jobId) {\n    if (hsProxy == null) {\n      try {\n        hsProxy = instantiateHistoryProxy();\n      } catch (IOException e) {\n        LOG.warn(\"Could not connect to History server.\", e);\n        throw new YarnRuntimeException(\"Could not connect to History server.\", e);\n      }\n    }\n    ClientServiceDelegate client = cache.get(jobId);\n    if (client == null) {\n      client = new ClientServiceDelegate(conf, rm, jobId, hsProxy);\n      cache.put(jobId, client);\n    }\n    return client;\n  }\n\n  protected synchronized MRClientProtocol getInitializedHSProxy()\n      throws IOException {\n    if (this.hsProxy == null) {\n      hsProxy = instantiateHistoryProxy();\n    }\n    return this.hsProxy;\n  }\n  ","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ClientCache.java#L45-L81","documentation":"Thrown by the MapReduce job client's ClientCache.getClient when instantiateHistoryProxy() fails with IOException — the client could not create an RPC proxy to the MapReduce JobHistoryServer. The IOException is wrapped in a YarnRuntimeException with this message, and both are logged at WARN. This is a client-side setup failure, not a job failure: every status poll after job completion goes through the history proxy, so this breaks job status/log retrieval.","triggerScenarios":"Running a MapReduce job on YARN where mapreduce.jobhistory.address points to a host/port with no running JobHistoryServer, or the JHS RPC port is firewalled/unreachable. Also when yarn.app.mapreduce.am.jobhistory... recovery data forces the client to consult history and the proxy creation (YarnRPC call) throws.","commonSituations":"JHS not started (most common in small/pseudo-distributed clusters); mapreduce.jobhistory.address left as 0.0.0.0:10020 in mapred-site.xml — 0.0.0.0 is not routable from remote clients; JHS bound to a different address than the one configured, or started after DNS change; Kerberos: missing jobhistory principal/keytab causing proxy setup IOException","solutions":["Verify the JobHistoryServer is running: check the process and http://<jhs>:19888/ws/v1/history/info","Set mapreduce.jobhistory.address to the JHS's routable hostname:10020 in mapred-site.xml and restart the client","Check firewall/network path to port 10020 from the client node","In Kerberos clusters confirm mapreduce.jobhistory.principal and keytab are correct so proxy creation succeeds"],"exampleFix":"<!-- before -->\n<property><name>mapreduce.jobhistory.address</name><value>0.0.0.0:10020</value></property>\n\n<!-- after -->\n<property><name>mapreduce.jobhistory.address</name><value>jhs.example.com:10020</value></property>\n<!-- ensure: mr-jobhistory-daemon.sh start historyserver -->","handlingStrategy":"retry","validationCode":"Configuration conf = new Configuration();\nString jhsAddr = conf.get(\"mapreduce.jobhistory.address\", \"0.0.0.0:10020\");\nString host = jhsAddr.split(\":\")[0];\nif (\"0.0.0.0\".equals(host)) throw new IllegalStateException(\n  \"mapreduce.jobhistory.address must be a routable hostname\");\n// optionally TCP-probe host:10020 before submitting jobs","typeGuard":null,"tryCatchPattern":"try {\n  client = clientCache.getClient(jobId);\n} catch (YarnRuntimeException e) {\n  if (e.getMessage().contains(\"Could not connect to History server\")) {\n    // fix env: start JHS / correct mapreduce.jobhistory.address, then retry\n    ensureJhsReachable(); client = clientCache.getClient(jobId);\n  } else throw e;\n}","preventionTips":["Start the JobHistoryServer before running MR jobs: mr-jobhistory-daemon.sh start historyserver","Configure mapreduce.jobhistory.address to a routable hostname:10020, never 0.0.0.0","Health-check JHS reachability in cluster bootstrap scripts and after restarts","Keep JHS principal/keytab valid in Kerberos clusters so proxy creation cannot fail"],"tags":["hadoop","mapreduce","yarn","jobhistory","rpc","connection","client-setup"],"backgroundTag":"service-unreachable","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}