{"record":{"id":"db853a86e1a4646a","repo":"TechnitiumSoftware/DnsServer","slug":"server-host-name-cannot-exceed-63-bytes-db853a","errorCode":null,"errorMessage":"Server host name cannot exceed 63 bytes.","messagePattern":"Server host name cannot exceed 63 bytes\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dhcp/Scope.cs","lineNumber":2001,"sourceCode":"        }\n\n        public IPAddress ServerAddress\n        {\n            get { return _serverAddress; }\n            set\n            {\n                ValidateIpv4(value, nameof(ServerAddress));\n                _serverAddress = value;\n            }\n        }\n\n        public string ServerHostName\n        {\n            get { return _serverHostName; }\n            set\n            {\n                if ((value != null) && (value.Length >= 64))\n                    throw new ArgumentException(\"Server host name cannot exceed 63 bytes.\");\n\n                _serverHostName = value;\n            }\n        }\n\n        public string BootFileName\n        {\n            get { return _bootFileName; }\n            set\n            {\n                if ((value != null) && (value.Length >= 128))\n                    throw new ArgumentException(\"Boot file name cannot exceed 127 bytes.\");\n\n                _bootFileName = value;\n            }\n        }\n\n        public IPAddress RouterAddress","sourceCodeStart":1983,"sourceCodeEnd":2019,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dhcp/Scope.cs#L1983-L2019","documentation":"Thrown by the ServerHostName setter when a non-null value has Length >= 64. DHCP server host names are bounded by the 64-byte sname field in the DHCP message, so the library rejects anything that would not fit (max 63 usable characters).","triggerScenarios":"Assigning scope.ServerHostName = value where value != null && value.Length >= 64. Occurs when the host name is an FQDN with many labels, a stale long value, or unvalidated user input.","commonSituations":"Config importing the machine FQDN verbatim, templated names that exceed 63 chars, or forgetting the 63-byte DHCP limit.","solutions":["Truncate or choose a host name of at most 63 characters before assignment.","Validate input length in your config/UI layer.","If the FQDN is too long, use a short hostname instead.","Note: the check is on character Length; for non-ASCII ensure byte length also stays under 64."],"exampleFix":"// before\nscope.ServerHostName = fqdn; // may exceed 63\n\n// after\nscope.ServerHostName = (fqdn == null || fqdn.Length <= 63) ? fqdn : fqdn.Substring(0, 63);","handlingStrategy":"validation","validationCode":"if (hostName != null && Encoding.UTF8.GetByteCount(hostName) >= 64)\n    throw new ConfigurationException(\"ServerHostName must be <= 63 bytes\");\nscope.ServerHostName = hostName;","typeGuard":"static bool IsValidServerHostName(string s)\n    => s == null || Encoding.UTF8.GetByteCount(s) <= 63;","tryCatchPattern":"try { scope.ServerHostName = value; }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Server host name\"))\n{ /* truncate and retry, or prompt user */ }","preventionTips":["Use a short hostname, not the full FQDN, for DHCP sname.","Validate length (and UTF-8 byte length for non-ASCII) in config.","Unit-test with a 64+ character input."],"tags":["dhcp","validation","scope","string-length","argument"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}