Skip to content
LIVE FEED

BlogHow to change HostName in Mac OS

Bố cục bài viết

Trang này

Sunex 24/07/2026 · 1 phút đọc

Ngày tạo

24/07/2026

Cập nhật

Lượt xem

9

Đọc

1m

Change Hostname on macOS

On macOS you can change the hostname (computer name) using the scutil command from Terminal. There are three related name settings.

Set the hostname

sudo scutil --set ComputerName "NewHostname"
sudo scutil --set HostName "NewHostname"
sudo scutil --set LocalHostName "NewHostname"

What each one does

  • ComputerName — the friendly name shown in Finder, System Settings, and AirDrop (can have spaces, e.g. “Anh’s MacBook Pro”)
  • HostName — used for command-line/network contexts, no spaces or special characters
  • LocalHostName — used for Bonjour/mDNS (.local name), also no spaces

Flush the cache

After running these, flush the mDNS cache so the change takes effect immediately:

dscacheutil -flushcache
sudo killall -HUP mDNSResponder

Verify

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

GUI method

You can also do it via the GUI: System Settings → General → About → Name (or on older macOS: System Preferences → Sharing → Computer Name).

Notes

  • Use only letters, numbers, and hyphens for HostName/LocalHostName — no spaces or underscores, or some network services may misbehave.
  • If you’re on a corporate/managed Mac (MDM), the hostname may get reset automatically by a config profile.
Contact
Facebook
TOP