2013-05-22 5 views
1

PHP 페이지에서 memcached 서버에 연결하려고하면 아무런 문제없이 작동합니다. 이 코드Memcache 연결이 cron 작업에서 오류를 throw합니다.

$memcache = new Memcache; 
$memcache->connect('localhost', 11211) or die ("Could not connect"); 

를 사용하지만 때 그것은이 오류이 문제를 일으킬 수 있습니다 무엇

Warning: Memcache::connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/...../cron/acts_cron.php on line 3 

Warning: Memcache::connect(): Can't connect to localhost:11211, php_network_getaddresses: getaddrinfo failed: Name or service not known (0) in /home/...../cron/acts_cron.php on line 3 
Could not connect 

을 던졌습니다 크론 작업에 의해 발사되는 PHP 스크립트에서 서버에 연결을 시도?

답변

0

로컬 호스트 대신 127.0.0.1을 사용하면 문제가 해결됩니다.

1

호스트 파일 내에 localhost 항목이 누락 된 것 같습니다./etc/hosts를 업데이트하고 다음과 같은 행이 있는지 확인하십시오.

127.0.0.1    localhost.localdomain localhost 
+0

이미 호스트 파일에이 줄이 있습니다. "127.0.0.1 \t localhost localhost.localdomain localhost4 localhost4.localdomain4" –

+0

페이지와 cron 스크립트를 실행하는 서버가 같은 서버입니까? – Curlas

+0

@Curlas 예, 동일한 서버 –

관련 문제