MAMP Pro adding entries to hosts file, changed my Terminal prompt

Joined
May 19, 2021
Messages
72
Reaction score
0
Points
6
I'm not sure where to post this, as MAMP's support forum is... strange... popping up giant ads all over the place, making me suspect that it's not legit, but here goes.

This pop-up appeared when I'd logged into the Mac (while away for an hour), which I thought had something to do with the T3 errors I was getting from my modem (not a modem problem, but an ISP problem as we discovered), but it might not be related at all:

1625843832020.png
I then noticed that my Terminal CLI prompt name changed from `Me@My-MacBook-Pro ~ %` to `Me@My-MacBook-Pro-2 ~ %`... I figured, OK weird, I'm not sure how that's related, but OK.

I then noticed in my `/etc/hosts` file that MAMP added entries, apparently tied to the internet connection issue and the command prompt name!

```
127.0.0.1 my-own-site.local # MAMP PRO - Do NOT remove this entry!
::1 my-own-site.local # MAMP PRO - Do NOT remove this entry!
127.0.0.1 My-MacBook-Pro-2.my.isp.net # MAMP PRO - Do NOT remove this entry!
::1 My-MacBook-Pro-2.my.isp.net # MAMP PRO - Do NOT remove this entry!
127.0.0.1 my-macbook-pro-2.local # MAMP PRO - Do NOT remove this entry!
::1 my-macbook-pro-2.local # MAMP PRO - Do NOT remove this entry!
```

This is really bizarre. I don't know how all of these things are tied together. Note that `my-own-site.local` is intentional because it's a site I have configured in MAMP Pro.

What's more bizarre is that now that MAMP Pro is closed, the Pro-2 entries are gone but my Terminal prompt is the same...

Can someone explain why the Terminal prompt change happened, and why it matches the hosts file change?! I'm not seeing documentation from MAMP Pro or Apple about this. I'm pretty sure MAMP Pro did something to the 'hostname', but I don't know why it added Pro-2 or changed it, and I don't know what happened to the original one. I just want things to be restored, and not weird, and hopefully not adding Pro-# incrementing names (hostnames?!) ad infinitum.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
16,037
Reaction score
2,444
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
The /etc/hosts file doesn't control your prompt but it looks like you have something in your bashrc/zshrc that might be referencing the hostname.

For starters, what version of macOS are you using? Show us the contents of your /etc/hosts file. Depending on whether you are running Bash or Zsh as the command line shell, show us your .bashrc or .zshrc.
 
OP
M
Joined
May 19, 2021
Messages
72
Reaction score
0
Points
6
> The /etc/hosts file doesn't control your prompt but it looks like you have something in your bashrc/zshrc that might be referencing the hostname.

There's nothing in my .zshrc file referencing the unexpected hostname (with -Pro-2 or -pro-2):

Bash:
me@My-MacBook-Pro-2 ~ % cat .zshrc
export PATH="/usr/local/sbin:$PATH"

# MAMP Pro recommended aliases for PHP 5.6
#alias php='/Applications/MAMP/bin/php/php5.6.40/bin/php -c "/Library/Application Support/appsolute/MAMP PRO/conf/php5.6.40.ini"'
#alias pear='/Applications/MAMP/bin/php/php5.6.40/bin/pear'
#alias pecl='/Applications/MAMP/bin/php/php5.6.40/bin/pecl'

# MAMP Pro custom aliases
alias php5=/Applications/MAMP/bin/php/php5.6.40/bin/php
alias camp='/Applications/MAMP/bin/php/composer'
alias tamp='tail -f /Applications/MAMP/logs/apache_error.log /Applications/MAMP/logs/php_error.log'

export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"

I haven't used the MAMP aliases for a while. I don't have a .bashrc file.

> For starters, what version of macOS are you using?

macOS Big Sur 11.4. It was originally purchased with Catalina (10.14 I think). It was .zsh by default.

> Show us the contents of your /etc/hosts file. Depending on whether you are running Bash or Zsh as the command line shell, show us your .bashrc or .zshrc.

I already showed that in the original post. Anything else there is irrelevant to this thread and exactly as expected (and isn't modified by MAMP). I've only used zsh on this Mac.

So, what would cause all three of these weird things to happen? The "hostname" in the screenshot being changed to "-Pro-2" (whatever it means by 'hostname'... can you explain?), the Terminal zshell command prompt being changed to "-Pro-2", and MAMP adding /etc/hosts entries for "-Pro-2" and "-pro-2". They seem to be related, but I can't figure out if MAMP did all this or something else is going on.
 
OP
M
Joined
May 19, 2021
Messages
72
Reaction score
0
Points
6
Nobody has any idea why this happened?

I'm concerned that this is a security issue.

I was asked for info by @Raz0rEdge and I provided it, but have gotten no reply for weeks.
 
Joined
Jan 1, 2009
Messages
16,379
Reaction score
4,735
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
Your system was renamed because the network software detected another entity in the network with the original name. To avoid confusion, yours was renamed. To get the original name back, open System Preferences, Sharing, unlock the pane, then change the Computer Name in the window. You don't have to add the .local, as it says right there that what is in the window will have .local added.
 
Last edited:

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
16,037
Reaction score
2,444
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Or better yet, I always name my machines something other than the generic names that Macs get like "John's Macbook Pro" and so on. All of my machines are named after constellations and as such I've never come across this issue.

This is not a security issue per say, just name your computer something unique and you'll be fine.
 
OP
M
Joined
May 19, 2021
Messages
72
Reaction score
0
Points
6
I appreciate the follow-up, but I don't know if what I've said or shown is being understood; I didn't name the Mac, it was unique on the network, and then suddenly, long after MAMP had been hosting local sites, I unlock the screen one day and get that error pop-up and suddenly my computer name and command prompt is changed, and /etc/hosts shows those weird modifications from MAMP.

I already mostly understood what happened, I just can't figure out why it happened, and I need to know why so it doesn't keep happening.

The answer that "well the name was already on the network" doesn't make sense when the only thing on the network named my computer was my computer. So, how does my computer suddenly think its own name is redundant to its own name on the network?! That would only make sense if another computer had the same name... but it's the only one with anything like that name. If macOS saw its own name on the network and somehow didn't realize it referred to itself, then that seems like a really bad idea to rename itself (across the whole OS) just for one network redundancy instance! That's goofy AF. As shown, it also changed my command prompt, which is not relegated to the network, but the OS. That's disruptive, no?

So, I can't tell if this is a Mac problem or a MAMP problem (as in, which one caused the problem?).

I'm pretty sure MAMP mucked with something somehow, though macOS' way of doing things may have contributed to it (maybe it's a macOS bug?! I don't know), and I think it has to do with its entries in /etc/hosts, but I can't make sense of how they all connect. Please look again at what I showed there above; the dots are not connected, the answers I'm seeing here are very basic and general and don't seem to explain the real why's or how to prevent the problem from happening again.
 
Last edited:
Joined
Oct 16, 2010
Messages
18,172
Reaction score
1,918
Points
113
Location
Brentwood Bay, BC, Canada
Your Mac's Specs
2020 27" i9 5K nano iMac, 1TB(partitioned) SSD, GB, macOS 15.3.1 Sequoia
I already mostly understood what happened, I just can't figure out why it happened, and I need to know why so it doesn't keep happening.


No doubt your Mac OS made it happen and I doubt very much if Apple is going to let you know how or why and just carry on and be prepared for it to happen again sometime in the future. It probably happens to attempt to keep your Mac working properly and maybe even safer and as a unique Network user.


- Patrick
=======
 
Joined
Jan 1, 2009
Messages
16,379
Reaction score
4,735
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
I appreciate the follow-up, but I don't know if what I've said or shown is being understood; I didn't name the Mac, it was unique on the network, and then suddenly, long after MAMP had been hosting local sites, I unlock the screen one day and get that error pop-up and suddenly my computer name and command prompt is changed, and /etc/hosts shows those weird modifications from MAMP.

I already mostly understood what happened, I just can't figure out why it happened, and I need to know why so it doesn't keep happening.

The answer that "well the name was already on the network" doesn't make sense when the only thing on the network named my computer was my computer. So, how does my computer suddenly think its own name is redundant to its own name on the network?! That would only make sense if another computer had the same name... but it's the only one with anything like that name. If macOS saw its own name on the network and somehow didn't realize it referred to itself, then that seems like a really bad idea to rename itself (across the whole OS) just for one network redundancy instance! That's goofy AF. As shown, it also changed my command prompt, which is not relegated to the network, but the OS. That's disruptive, no?

So, I can't tell if this is a Mac problem or a MAMP problem (as in, which one caused the problem?).

I'm pretty sure MAMP mucked with something somehow, though macOS' way of doing things may have contributed to it (maybe it's a macOS bug?! I don't know), and I think it has to do with its entries in /etc/hosts, but I can't make sense of how they all connect. Please look again at what I showed there above; the dots are not connected, the answers I'm seeing here are very basic and general and don't seem to explain the real why's or how to prevent the problem from happening again.
So, I'll try to make it simple. Your Mac has two or more interfaces to network with. Ethernet is one and WiFi is another. For the example, your Ethernet port has obtained an IP number from your router and shared the default computer name, which is your account plus "-MacBook-Pro" added and ".local" added to show that the account is local. You may or may not have "named" the machine, but in the network it has a name and that is the default when you don't do anything.

Now, you turn on WiFi and it connects to the router and says hey, I'm xxxx-MacBook-Pro.local" and I want an IP. The router returns, "Not so fast, we already have a machine with that name," and the OS then says, "OK, I'll be xxxx-MacBook-Pro2.local, then. The router issues the IP and notes the new name. But that rename now propagates through the settings on the MBP and changes the default prompt in Terminal to be the new name.

As for what MAMP may or may not do, I have no idea. But I don't have MAMP installed and I've occasionally seen the renaming dialog so it can happen without MAMP. What I do to "fix" it is to cycle the router off and on and reboot the Mac so that both start with a fresh state. The two interfaces I use, Ethernet and WiFi, then get good IPs and nobody get renamed.
 
OP
M
Joined
May 19, 2021
Messages
72
Reaction score
0
Points
6
So, I'll try to make it simple. Your Mac has two or more interfaces to network with. Ethernet is one and WiFi is another. For the example, your Ethernet port has obtained an IP number from your router and shared the default computer name, which is your account plus "-MacBook-Pro" added and ".local" added to show that the account is local. You may or may not have "named" the machine, but in the network it has a name and that is the default when you don't do anything.

Now, you turn on WiFi and it connects to the router and says hey, I'm xxxx-MacBook-Pro.local" and I want an IP. The router returns, "Not so fast, we already have a machine with that name," and the OS then says, "OK, I'll be xxxx-MacBook-Pro2.local, then. The router issues the IP and notes the new name. But that rename now propagates through the settings on the MBP and changes the default prompt in Terminal to be the new name.

OK, so, I think this is what I understood basically from the previous description; the problem with that explanation is that I've never seen an OS change its own computer name just for one router connection instance happening to have the same name. If that's how it works... that would probably happen a lot, not just this one time over 4 months on this Mac (and never on any other computer I've ever used over [a long time]). Even if it happened once every 5 years, to me that's a problem (bug or design flaw) with the OS, because a network router shouldn't cause the OS to change its own computer name... that seems completely backwards to how it should work. It's not only disruptive for me the user, but I'd think it make the OS or me more vulnerable to network spoofing or some other weird security vulnerabilities (or social engineering?!). The router should just drop that connection, or the OS should show me a warning and ask if I want to rename the computer (?!) just to connect to the router again... I wouldn't have opted for that, I didn't think I clicked to agree to it, but maybe I misread what macOS was saying. If it just changed the name anyway... I consider that bad policy.

I think I've realized however based on your more detailed explanation that the initial prompt was telling me how to change it back (well, to whatever I want I guess), but I'm just saying that I deal in command-line and local servers so I'm hoping me modifying it and what you're saying won't interfere with anything in a significant way, though I don't mind if I lose my router connection and can just reconnect.

As for what MAMP may or may not do, I have no idea. But I don't have MAMP installed and I've occasionally seen the renaming dialog so it can happen without MAMP. What I do to "fix" it is to cycle the router off and on and reboot the Mac so that both start with a fresh state. The two interfaces I use, Ethernet and WiFi, then get good IPs and nobody get renamed.

I only thought MAMP caused it because I noticed the `-2` entries in /etc/hosts marked as 'created by MAMP'... so that may be completely coincidental. Hopefully it's not tangling itself up in this (or causing it), but I'm ultimately just trying to avoid this nonsense because that's exactly what it looks like, nonsense.

Anyway, I'll just blame Big Sur because I've not seen this on previous OS platforms or versions, and I've been using Windows since [XP] and Mac since Sierra, with random Linux try-outs.

I'll try shutting down the Mac and all computers and devices connected to the router, then reboot the router, but I'm hoping this won't be a new rat's nest of issues or keep happening; I used to connect to shared resources using internal IP but I think I don't ever need that for typical folder sharing.
 
Joined
Jan 1, 2009
Messages
16,379
Reaction score
4,735
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
Anyway, I'll just blame Big Sur because I've not seen this on previous OS platforms or versions, and I've been using Windows since [XP] and Mac since Sierra, with random Linux try-outs.
Not Big Sur, I've seen it on just about every version from Snow Leopard on. It's the router trying to avoid conflicts that sets the share name. Not a big deal, as I said, just reset the router and reboot the machine. The "2" comes from the rename process. How that rename gets into the shell in Terminal is probably a result of putting the machine share in the prompt. My prompt has my login, plus "@" and the machine name as shared, so that is how it could happen to me.

Haven't been on Windows in a long time, but network management software will resolve name conflicts in all versions of all OS for all kinds of machines. Bottom line is that no two machines can have the same share name in the network or all kinds of crazy happens.
 
OP
M
Joined
May 19, 2021
Messages
72
Reaction score
0
Points
6
My prompt has my login, plus "@" and the machine name as shared, so that is how it could happen to me.

I'm not sure what "machine share in the prompt" means... I just find it ridiculous that Apple allows a router conflict to change the command prompt name. The latter should not rely on the former. A router conflict should be handled at a different layer, not force the computer to change its own name... that's just bizarre. Maybe I misclicked and should have clicked something else because Apple thought I wanted the name changed, I don't know.

Haven't been on Windows in a long time, but network management software will resolve name conflicts in all versions of all OS for all kinds of machines. Bottom line is that no two machines can have the same share name in the network or all kinds of crazy happens.

I've had conflicts on Windows and never seen it change the computer name or CLI prompt name. At worst, I've seen the network connection name change (like Network Connection 2, 3, 4, etc), but not like what macOS did here. It's just bizarre. It seems like macOS letting a router conflict change the computer's name opens up the computer for hacking from spoofing or something like that.

Anyway, thanks for the info and suggested fixes. I probably just clicked the wrong thing somewhere.
 
Joined
Jan 1, 2009
Messages
16,379
Reaction score
4,735
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
machine share in the prompt
Not sure what you mean by that. But here is my Terminal prompt:

Screen Shot 2021-09-08 at 2.35.07 PM.png

I blotted out my login name, but the "@MBP15" is the share name of my Mac as it appears in the System Preferences/Sharing pane:

Screen Shot 2021-09-08 at 2.37.40 PM.png

As it says, that is the network name. You add ".local" to access my Mac from my network, so MBP15.local is the address. If there is a network conflict perceived by the router, the network name will become "MBP15-2" and the network address will be "MBP15-2.local." I suspect my Terminal prompt will then pick up the MBP15-2 as well. When I reboot, I suspect it will go back to my assigned MBP15 unless it sees the same conflict again.
 
OP
M
Joined
May 19, 2021
Messages
72
Reaction score
0
Points
6
Not sure what you mean by that.

You first mentioned "machine share in the prompt" (on your Aug 13, 2021 comment)... I said I don't know what you mean by that. So what did you mean by that? The share name of your Mac?

But here is my Terminal prompt:

View attachment 34675

I blotted out my login name, but the "@MBP15" is the share name of my Mac as it appears in the System Preferences/Sharing pane:

View attachment 34676

As it says, that is the network name. You add ".local" to access my Mac from my network, so MBP15.local is the address. If there is a network conflict perceived by the router, the network name will become "MBP15-2" and the network address will be "MBP15-2.local." I suspect my Terminal prompt will then pick up the MBP15-2 as well. When I reboot, I suspect it will go back to my assigned MBP15 unless it sees the same conflict again.

My Sharing Computer Name is My MacBook Pro; underneath that it says "Computers on your local network can access your computer at: My-MacBook-Pro-2.local, then an Edit button next to that, like in your screenshot. When I click the Edit button, it says "Use this name to reach this computer from machines on your local subnet." with "Local Hostname: My-MacBook-Pro-2.local" (with the part before .local being editable).

So, I can change that there. What doesn't make sense is that it changes my Terminal prompt; why would it use my share name?! I'm not accessing my Terminal through the network, I'm accessing it directly in my user session directly connected to the Mac through my keyboard. Does Windows work like this?! I've never seen this kind of thing before, a router conflict should not change my Terminal prompt, it's silly.
 
Joined
Jan 1, 2009
Messages
16,379
Reaction score
4,735
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
You can change it: Moving to zsh, part 6 – Customizing the zsh Prompt

The zsh shell that Terminal uses can be configured, as the article says. The default name is the username followed by the host name. The host name is what is in the shared name for the local network share. As has been said before, if the router sees a conflict when it assigns the IP through DHCP, the Mac will change the share name to remove the name conflict. That then becomes the Hostname that is shown in the terminal prompt. If it bothers you, change it.
 
OP
M
Joined
May 19, 2021
Messages
72
Reaction score
0
Points
6
You can change it: Moving to zsh, part 6 – Customizing the zsh Prompt

The zsh shell that Terminal uses can be configured, as the article says. The default name is the username followed by the host name. The host name is what is in the shared name for the local network share. As has been said before, if the router sees a conflict when it assigns the IP through DHCP, the Mac will change the share name to remove the name conflict. That then becomes the Hostname that is shown in the terminal prompt. If it bothers you, change it.

Right, I already understood that.

I don't think this addresses the fact that a router conflict shouldn't change my command prompt name; the idea seems silly. I'm fine if your opinion is that it should (and no point in saying again that it will or how it will). Windows' CLI prompt name doesn't change if the computer has a router IP conflict (like one of mine did recently), so I disagree that it should change Mac's CLI prompt name. Maybe the way macOS is designed makes that unstoppable, but if so, then I disagree with Apple's design decision here, I consider it disruptive and I'll bet a security risk.
 
Joined
Jan 1, 2009
Messages
16,379
Reaction score
4,735
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
It has zero, repeat, zero to do with anything Apple. The default zsh prompt includes user and hostname. The hostname is changed to resolve the name conflict and the zsh shell picks up that change. If you don't want that, just change the prompt. It's easy to do. The fact that the mess that is Windows CLI doesn't do the same thing doesn't have any bearing on this.

Bottom line, if you don't want the Terminal prompt, provided by zsh, to show the hostname, just change it. But don't blame Apple, blame zsh. Apple's not blocking that change, it's entirely up to you. In fact, you don't even have to use zsh if you don't want to. How to Change the Default Shell to Bash on macOS Catalina I just tested and it works on Big Sur, particularly the part about using System Preferences.

And the thought that somehow an internal name change is a security risk is just laughable.

I'm done, we've given you everything you need to know about why it's happening and how to make it not happen. You can change it or live with it.
 
OP
M
Joined
May 19, 2021
Messages
72
Reaction score
0
Points
6
It has zero, repeat, zero to do with anything Apple. The default zsh prompt includes user and hostname. The hostname is changed to resolve the name conflict and the zsh shell picks up that change. If you don't want that, just change the prompt. It's easy to do. The fact that the mess that is Windows CLI doesn't do the same thing doesn't have any bearing on this.

You just described how it has to do with Apple 😆 because Windows doesn't do that when it has a conflict, which I get sometimes on it when I get a similar pop-up. My PowerShell prompt doesn't change its name or anything after that. If the difference is that Apple uses the hostname for the prompt regardless of what it is, then that's still a completely Apple decision, which is unfortunately a bit disruptive and distracting. I guess Microsoft did it right in this instance... and regardless, I have zero use for the command prompt to show me my computer's hostname, especially if it'll change due to the router having an IP conflict :/ No good there, Apple.

Bottom line, if you don't want the Terminal prompt, provided by zsh, to show the hostname, just change it. But don't blame Apple, blame zsh. Apple's not blocking that change, it's entirely up to you. In fact, you don't even have to use zsh if you don't want to. How to Change the Default Shell to Bash on macOS Catalina I just tested and it works on Big Sur, particularly the part about using System Preferences.

I did change it. I already understood previously to do that. That's another irritation based on Apple's decision, or if it's zsh's fault, well, Apple chose to use zsh as its default for Catalina, which carries over to Big Sur, both of which I've been using. If I can change Apple or zsh using the router-changeable (basically) hostname, great, I'll do that. No further discussion needed.

And the thought that somehow an internal name change is a security risk is just laughable.

I'm sorry you feel that way, but maybe you've never worked in infosec or seen how surprising spoofing can be on customers. Just think of all the ways...

I'm done, we've given you everything you need to know about why it's happening and how to make it not happen. You can change it or live with it.

Great! Thanks for the input or whatever.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top