{
  "id": "mongodb/replica-set-hostname-mismatch",
  "signature": "MongoServerError: hostname mismatch: expected 'host1.example.com' but found 'host2.example.com'",
  "signature_zh": "MongoServerError: 主机名不匹配：期望 'host1.example.com' 但发现 'host2.example.com'",
  "regex": "hostname mismatch: expected '([^']+)' but found '([^']+)'",
  "domain": "mongodb",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Replica set member hostnames in the configuration do not match the actual hostnames resolved by DNS or /etc/hosts, causing authentication or membership verification failures.",
  "root_cause_type": "generic",
  "root_cause_zh": "副本集成员配置中的主机名与 DNS 或 /etc/hosts 解析的实际主机名不匹配，导致身份验证或成员资格验证失败。",
  "versions": [
    {
      "version": "mongodb-4.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb-4.4",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb-5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb-6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "mongodb-7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The replica set configuration is stored in the local database and requires reconfiguration via rs.reconfig(), not a file change.",
      "fail_rate": 0.25,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using 'localhost' prevents other members from connecting; each member must use a reachable hostname.",
      "fail_rate": 0.2,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This corrupts the replica set state and requires a full re-initialization, causing data loss.",
      "fail_rate": 0.1,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Update the replica set configuration to match the actual hostnames using rs.reconfig(). Example: `cfg = rs.conf(); cfg.members[0].host = 'actual-hostname:27017'; rs.reconfig(cfg);`",
      "success_rate": 0.9,
      "how": "Update the replica set configuration to match the actual hostnames using rs.reconfig(). Example: `cfg = rs.conf(); cfg.members[0].host = 'actual-hostname:27017'; rs.reconfig(cfg);`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add entries to /etc/hosts on all replica set members to map the expected hostnames to the correct IP addresses. Example: `echo '192.168.1.10 host1.example.com' >> /etc/hosts`.",
      "success_rate": 0.85,
      "how": "Add entries to /etc/hosts on all replica set members to map the expected hostnames to the correct IP addresses. Example: `echo '192.168.1.10 host1.example.com' >> /etc/hosts`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using Docker, ensure container names match the hostnames in the replica set config and that they are on the same network. Example: `docker run --name host1 --network mynet ...`",
      "success_rate": 0.8,
      "how": "If using Docker, ensure container names match the hostnames in the replica set config and that they are on the same network. Example: `docker run --name host1 --network mynet ...`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Update the replica set configuration to match the actual hostnames using rs.reconfig(). Example: `cfg = rs.conf(); cfg.members[0].host = 'actual-hostname:27017'; rs.reconfig(cfg);`",
    "Add entries to /etc/hosts on all replica set members to map the expected hostnames to the correct IP addresses. Example: `echo '192.168.1.10 host1.example.com' >> /etc/hosts`.",
    "If using Docker, ensure container names match the hostnames in the replica set config and that they are on the same network. Example: `docker run --name host1 --network mynet ...`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/tutorial/deploy-replica-set-for-testing/",
  "official_doc_section": null,
  "error_code": "93",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2023-09-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}