简体   繁体   English

XCode:无效的主机字符串'localhost'

[英]XCode: Invalid host string 'localhost'

I'm getting this error: "Invalid host string: 'localhost'" every time I try to compile code on my laptop. 每当我尝试在笔记本电脑上编译代码时,我都会收到此错误:“无效的主机字符串:'localhost'”。 My desktop, however, works just fine. 但是,我的桌面工作正常。

Both the laptop and the desktop have the exact same hosts file in etc/hosts, that is: 便携式计算机和台式机在etc / 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
fe80::1%lo0     localhost

I've searched so much around the internet and all of them have the same answer: Your hosts file is named incorrectly. 我在互联网上进行了很多搜索,所有这些都得到了相同的答案:您的主机文件命名不正确。 But it's not. 但事实并非如此。

It's named hosts. 它被称为主机。 I have made two copies, hosts.txt and just hosts and neither of them work. 我已经制作了两个副本,hosts.txt和只是主机,它们都不起作用。 This leads me to think it's something in XCode's preferences that's looking for hosts somewhere else. 这使我认为XCode的首选项中正在寻找其他地方的主机。

Can you mention your OS ? 你能提到你的操作系统吗?

Mostly MAC OS X lion giving this error because Apple remove web sharing from 10.8.x 大多数情况下,MAC OS X lion出现此错误是因为Apple从10.8.x删除了网络共享

If your OS is 10.8.x then use this link. 如果您的操作系统是10.8.x,请使用此链接。 http://reviews.cnet.com/8301-13727_7-57481978-263/how-to-enable-web-sharing-in-os-x-mountain-lion/ http://reviews.cnet.com/8301-13727_7-57481978-263/how-to-enable-web-sharing-in-os-x-mountain-lion/

After implementing this link just restart your system 实现此链接后,只需重新启动系统

Enjoy... 请享用...

I was running against the same problem on a run-time of xcode debug. 我在xcode调试的运行时遇到了相同的问题。 Are you running gas mask? 你在跑防毒面具吗? If so, I was simply under the remote file rather than the local in my settings. 如果是这样,我只是在远程文件下,而不是在我的设置中的本地下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM