View Full Version : Cant build any programs. Error --invalid host string 'localhost'

Jun 8, 2012, 08:52 PM
I am trying to run in command line tool the following code:

#import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool {

// insert code here...
NSLog(@"Hello, World!");

return 0;

and after "Build Succeeded" I am getting the following error:

error: failed to launch '/Users/rrusnac/Library/Developer/Xcode/DerivedData/5.1_Practice-gdhkgzautnruix bnobucittithbz/Build/Products/Debug/5.1 Practice ' --invalid host string: 'localhost'

It doesnt matter what code I enter, I get the same error. I cant figure out for the life of me why this is happening. I am running Xcode 4.3.2 and Lion 10.7.4.

The programs build and run with no Issues, but this error always pops up. Please help me!

Jun 26, 2012, 05:19 AM
Check your /etc/hosts file and make sure it contains an entry for localhost. Default /etc/hosts should have the following entries localhost broadcasthost
::1 localhost
fe80::1%lo0 localhost

Jun 26, 2012, 06:21 AM
Found a similar-sounding SO post:


Jul 17, 2014, 07:36 PM
Check this forum out:

Just running `dscacheutil -flushcache` in the terminal worked for me!