簡體   English   中英

fsockopen()無法連接到www.google.com:80

[英]fsockopen() unable to connect to www.google.com:80

使用fsockopen()或file_get_contents()函數時遇到一些問題

$test = fsockopen("www.google.com", 80, $errno, $errstr, 30);

還給我

Warning: fsockopen(): unable to connect to www.google.com:80 (Connection timed out) 

已注冊的流套接字傳輸tcp,udp,unix,udg,ssl,tls,tlsv1.0,tlsv1.1,tlsv1.2

allow_url_fopen =開

我在php7-fpm + nginx vps上運行,無法正常工作。

更新使fsockopen到IP地址的工作原理...

這是我的etc / resolv.conf

nameserver 213.133.99.99
nameserver 213.133.100.100
nameserver 213.133.98.98

UPDATE curl -vvv http://www.google.com響應

* Hostname was NOT found in DNS cache
*   Trying 2a00:1450:4001:811::2004...
*   Trying 216.58.214.68...
* Connected to www.google.com (216.58.214.68) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.38.0
> Host: www.google.com
> Accept: */*
>
< HTTP/1.1 302 Found
< Cache-Control: private

謝謝

根據您對上一個答案的評論,聽起來您的IP已被Google阻止,或者您的DNS設置已損壞。

嘗試卷曲時會發生什么:

$ curl -vvv http://www.google.com/

如果是DNS問題,則可以直接訪問IP:

$ curl 64.233.162.99

如果不起作用,請嘗試其他站點,例如:

$ curl -vvv http://www.stackoverflow.com/

您正在運行什么OS和VPS?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM