php copy failed to open stream connection timed out
Why is the browser returning this error?
4 Answers 4
Mostly probably your server cannot connect to an external resource, for example, because of firewall restrictions.
file_get_contents does not work well at all with getting remote files and should not be used. It does not deal with slow network connections or redirects, and does not return error codes. You should use curl instead to fetch remote files.
I had the same problem, couldn’t download using file_get_contents(), but using curl on the command line for the same URL worked fine. Turned out it tried to connect over IPv6 which failed.
I solved it by disabling IPv6 in my kernel parameters.
It might be server side issue, might be your server cannot communicate with other server remotely. You have to communicate with server administrator.
Not the answer you’re looking for? Browse other questions tagged php or ask your own question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.9.17.40238
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Warning: file_get_contents failed to open stream: Connection timed out in includes/simple_html_dom.php on line 75
All of a sudden my cronjob has stopped working properly where it grabs content through file_get_contents and started giving the following warning and fatal error. Does anyone know why it is doing this?:
2 Answers 2
It may be execution problem.
The Connection timed out error is a network problem for sure.
First, that’s maybe your network connection problem take too long to get response from server. Please check your local/server/hosting internet connection; domain name, IP, port. typo.
Not the answer you’re looking for? Browse other questions tagged php or ask your own question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.9.17.40238
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
How to fix «failed to open stream: Connection timed out in. » when using file_get_contents and get_bloginfo?
When I use file_get_contents with get_bloginfo it seems to work fine when I am working on the site locally and on the staging server. However when the site goes live it stops working and gives me this error «Warning: file_get_contents(https://www.websiteurl.com/wp-content/themes/theme-name/assets/svg/logo.svg): failed to open stream: Connection timed out in /home/websiteurl/public_html/wp-content/themes/theme-name/header.php on line 38.
When I open this link https://www.websiteurl.com/wp-content/themes/theme-name/assets/svg/logo.svg the svg loads just fine. So why does it give me this error?
Here is the current code:
When I change it to this the error goes away:
Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.
Browse other questions tagged php wordpress or ask your own question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.9.17.40238
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.