<!--
{
  "availability" : [
    "macOS: 10.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SystemConfiguration",
  "identifier" : "/documentation/SystemConfiguration/SCPreferencesSetLocalHostName(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "System Configuration"
    ],
    "preciseIdentifier" : "c:@F@SCPreferencesSetLocalHostName"
  },
  "title" : "SCPreferencesSetLocalHostName(_:_:)"
}
-->

# SCPreferencesSetLocalHostName(_:_:)

Sets the local host name to the specified name.

```
func SCPreferencesSetLocalHostName(_ prefs: SCPreferences, _ name: CFString?) -> Bool
```

## Parameters

`prefs`

The preferences session.

`name`

The local host name. This string must conform to the naming conventions of a DNS host name as specified in RFC 1034 (section 3.5).

## Return Value

`TRUE` if successful; otherwise, `FALSE`.

## Discussion

To commit these changes to permanent storage you must call the [`SCPreferencesCommitChanges(_:)`](/documentation/SystemConfiguration/SCPreferencesCommitChanges(_:)) function. In addition, you must call the [`SCPreferencesApplyChanges(_:)`](/documentation/SystemConfiguration/SCPreferencesApplyChanges(_:)) function for the new name to become active.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)