1.打开终端,查看 hostname
hostname
显示结果为xxMacBook-Pro.local
2.查看 hosts 文件
cd /etc
open hosts
显示
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
原因
hostname 和 hosts 文件里的 hostname 不一致,也就是本机hostname为.local而hosts文件中的hostname为localhost
解决办法
修改 hostname 与 hosts
sudo scutil --set HostName localhost
网友评论