解决fsockopen(): unable to connect to google.com:80
每次发表完新日志,或编辑文章发布时,总会出现一串代码错误Warning,在评论时也会出现类似错误。虽然不影响发表和评论结果,但每次出现这样的错误,还是搞的很恐怖。今天终于在WordPress官方论坛寻得良方。
错误代码:
Warning: fsockopen(): unable to connect to google.com:80 in /wp-admin/post.php
d:\clientweb\dreamfree\wwwroot\wp-includes\class-snoopy.php on line 1158
Warning: Cannot modify header information – headers already sent by (output started at d:\clientweb\dreamfree\wwwroot\wp-includes\class-snoopy.php:1158) in d:\clientweb\dreamfree\wwwroot\wp-includes\pluggable.php on line 685
以及保存草稿时:
Warning: Cannot modify header information – headers already sent by (output started at d:\clientweb\dreamfree\wwwroot\wp-includes\class-snoopy.php:1158) in d:\clientweb\dreamfree\wwwroot\wp-includes\classes.php on line 805
解决方法:
打开/wwwroot/wp-settings.php,找到71行附近,插入 if ( isset($_SERVER['PATH_INFO']) ) {…..}语句,至// Append the query string if it exists and isn’t null上方结束,即修改为以下格式,
// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
if ( isset($_SERVER['PATH_INFO']) ) {
if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
else
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; }
// Append the query string if it exists and isn’t null
虽然是代码盲,其实大概可以看出来,这是windows iis主机出现的错误,很可能是和我以前为了去掉链接地址中的index.php设置win主机静态链接的方法不兼容,因为修改链接之前没此类错误。当然wordpress 2.5之后的版本已经修正了这个问题,既然找到解决方法,还是等到wordpress 2.7好了。
PS:这个方法只能解决部分问题,有多出来个Fatal error: Maximum execution time of 60 seconds exceeded in d:\clientweb\dreamfree\wwwroot\wp-content\plugins\google-sitemap-generator\sitemap.php on line 2303,晕了。

延伸阅读:
11 Responses to “解决fsockopen(): unable to connect to google.com:80”
Leave a Reply



我来消灭0回复~
最近在你的网站上留言,留完后也会出现类似的问题~
好像问题已经解决了~
留言问题解决了?不过我撰写日志后台还是有点问题。
但还好不影响最终发布结果,只是要蹦出那代码错误页面。
还好主机是头文字L
强大的Linux or LAMP..
我的也出现过类似情况,不知道2.7会不会解决此问题。
wp 2.5以后的版本已经修正这个问题啦,只不过我比较懒,一直没升级,呵呵。
很少出现 ,但的确出现过…不知什么原因…
那是你曾经用了一个插件,网上说和一些插件不兼容。
我以前也有一个error, 不过那时插件作者没有考虑配置项空白的情况, 填一些东西就可以了
好像是一个翻译插件冲突,我禁用了几个不大常用的插件,好像最近就没出现这种错误提示了。