Hostname keeps changing on MacBook running macOS Sonoma

On my MacBook7,1 macOS Sonoma 14.7.6 (23H626).

My hostname always was a "Daniels-MacBook", but suddenly it was changed to "109addb483c9". And when i changed it back, after ~90 mins it was back again. Reboot didn't help


[Re-Titled by Moderator]

Original Title: Hostname keeps changing

MacBook

Posted on Jul 22, 2025 04:22 AM

Reply
2 replies

Jul 22, 2025 05:15 AM in response to Danil_768

MacBook Hostname Persistently Changing? Here's How to Fix It.

If your MacBook's hostname is unexpectedly reverting to a random string of characters on macOS Sonoma, you're not alone. This frustrating issue, where a custom name like "Daniels-MacBook" is replaced by something like "109addb483c9," is often tied to network configurations and how macOS manages device identification. Even after a reboot, the problem can resurface, but there are definitive steps to reclaim your desired hostname.

The root of this problem typically lies in the interaction between your MacBook and the network's DHCP (Dynamic Host Configuration Protocol) server, which assigns IP addresses and can also dictate hostnames. Conflicts with other devices, or even having multiple network connections active (like Wi-Fi and Ethernet), can also trigger these unwanted changes.

To permanently set your hostname, you'll need to ensure all three of your Mac's designated names—the Computer Name, Local Hostname, and the System HostName—are correctly configured.

The Definitive Fix: Setting All Hostnames via Terminal

The most robust method to resolve this issue is to use the Terminal to explicitly set all three system names. This makes your chosen name more resilient to network-inflicted changes.

  1. Open the Terminal app: You can find it in your /Applications/Utilities/ folder, or by searching for "Terminal" using Spotlight.
  2. Execute the following commands one by one: Press Enter after each line. You will be prompted to enter your administrator password for the first command; you won't see the characters as you type.

Bash


sudo scutil --set ComputerName "Daniels-MacBook"
sudo scutil --set LocalHostName "Daniels-MacBook"
sudo scutil --set HostName "Daniels-MacBook"

Replace "Daniels-MacBook" with your desired hostname in each command.

  1. Verify the changes: To confirm that all three names have been updated, you can use the following commands:

Bash


scutil --get ComputerName
scutil --get LocalHostName
scutil --get HostName

Each command should now return the hostname you have just set.

Additional Troubleshooting Steps

If the issue persists after setting the hostnames, consider these additional steps:

  • Renew Your DHCP Lease: This forces your MacBook to request fresh network information from your router.
    • Go to System Settings > Network.
    • Select your active network connection (e.g., Wi-Fi).
    • Click Details..., then go to the TCP/IP tab and click Renew DHCP Lease.
  • Check Network Service Order: If you use both Wi-Fi and a wired connection, prioritize the one you use most.
    • In System Settings > Network, click the three-dot menu (...) at the bottom and select Set Service Order.
    • Drag your primary connection to the top of the list and click OK.
  • Flush DNS Cache: To clear out any old or incorrect network information, open Terminal and run:
  • Bash

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • Review Conflicting Software: In some cases, VPN clients, virtualization software like Docker, or other network-monitoring tools can interfere with your Mac's hostname. The random string you're seeing is sometimes indicative of a Docker container ID. If you have such software installed, try temporarily disabling it to see if the problem resolves.

By taking these steps, you should be able to stabilize your MacBook's hostname and prevent it from being overridden by network settings.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Hostname keeps changing on MacBook running macOS Sonoma

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.