My Terminal hostname suddenly changed to an AirPlay device name

Spent days on this then suddenly find out the source, but I still can't address the problem.

On Terminal, my hostname is "Samsung". Despite this has never happened before (it always has been showed up as MacBook-Pro-di-Giuliano) and I do not know why it happened now, I think that it is because I have both my MacBook Pro and a Samsung TV connected to the same WiFi. In fact, when I connect my Mac to a different network as my iPhone router, the Terminal hostname is "correct" (MacBook-Pro-di-Giuliano).


That's obviously annoying and I can't solve it.

I also tried to configure something in AirDrop & Handoff but got no points. The Apple Support neither gave me a valid solution...

On settings, and even by using the `scutil`command, I can see that my local hostname is correct.

MacBook Pro 16″, macOS 14.4

Posted on Mar 17, 2024 11:46 AM

Reply
Question marked as Top-ranking reply

Posted on Mar 18, 2024 2:12 AM

As already noted, this "Samsung" is not your mac hostname.

It is appearing there due to how your shell prompt was customized.


What is the output of the following command in Terminal:


echo $PROMPT


14 replies

Mar 19, 2024 10:41 AM in response to giulianoaiello

primary hostname of the Mac:

sudo scutil --set HostName <new host name>


Bonjour hostname of your Mac (local network):

sudo scutil --set LocalHostName <new host name>


change the computer name (computer name you see in finder):

sudo scutil --set ComputerName <new name>


dscacheutil -flushcache


restart Mac


I would force all three (or at least Hostname and LocalHostName) with 'MacBook-Pro-di-Giuliano'

Mar 17, 2024 2:34 PM in response to giulianoaiello

giulianoaiello wrote:

Spent days on this then suddenly find out the source, but I still can't address the problem.
On Terminal, my hostname is "Samsung". Despite this has never happened before (it always has been showed up as MacBook-Pro-di-Giuliano) and I do not know why it happened now, I think that it is because I have both my MacBook Pro and a Samsung TV connected to the same WiFi. In fact, when I connect my Mac to a different network as my iPhone router, the Terminal hostname is "correct" (MacBook-Pro-di-Giuliano).



you can customize your zsh prompt...


https://www.makeuseof.com/customize-zsh-prompt-macos-terminal/


Mar 18, 2024 1:04 PM in response to kolella

Executing `sudo scutil --get LocalHostName` (not `HostName`) already gives me "MacBook-Pro-di-Giuliano" (in fact, it's the same thing I specified in my first attached image in System Settings).

If I execute `hostname` it prompts me "Samsung.station", instead. That's the strangest thing, I don't get the difference between the two commands.

Anyway, I can execute `sudo hostname MacBook-Pro-di-Giuliano.local` and the problem is fixed, but just for minutes... Afterwards, if I log into some new Terminal tabs the hostname is "Samsung.station" again (although this `hostname` command should set permanently the hostname)...

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.

My Terminal hostname suddenly changed to an AirPlay device name

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