Andy W
Andy W

Reputation: 21

Localhost not working mac terminal

Trying to run localhost to test a website in mac osx terminal.

andys-mbp:test Andy$ cd /Users/Andy/Desktop/test 
andys-mbp:test Andy$ php -S localhost:8000

This would usually work, but now I'm getting this error message:

Warning: Unknown: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in Unknown on line 0
[Tue Feb 24 12:55:58 2015] Failed to listen on localhost:8000 (reason: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known)

I've followed this tutorial to make sure PHP and apache are running, but it didn't seem to help...

How can I fix this? Any help very much appreciated!

Upvotes: 2

Views: 7801

Answers (2)

Andy W
Andy W

Reputation: 21

Used ls -la on the /etc folder, and found the permissions were a bit strange on the hosts file... Restarted and all fine now... Thanks everyone for your help... very strange.

Upvotes: 0

rLinhares
rLinhares

Reputation: 367

i think this guy has the same problem of you.. http://goo.gl/LQ0RgM

maybe you just need update your /etc/hosts, like commented on link:

The problem was with the host file. Fixed it by adding this to the /etc/hosts file:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.1.1 <hostname>

Upvotes: 8

Related Questions