I have a website (www.example.com | 123.456.789), in that machine i only have 1 web app running. i am trying to use php file_get_content() to a file which in my own server (located on some file like /var/www/my_site/public_html).

However it always returns error. When i try to do it manually, using CURL

Curl command

I can confirm that i can CURL other website such as ~$ curl google.com Can anyone suggest me what to do to resolve this. Thanks

I am using Ubuntu 14.04 LTS to host my webapp.

  • What happens when you use file_get_contents() instead of curl? That would seem like a more appropriate function for getting the contents of a file. – Ladadadada Oct 20 '15 at 5:28
  • returns false followed by the full URL where the CURLed file resides. – Jeremy Oct 20 '15 at 5:33
  • Are the addresses that it tried to connect to correct (see the lines where you get the Connection timed out errors)? – Håkan Lindqvist Oct 20 '15 at 5:46
  • @HåkanLindqvist it reverts back to the IP address of my server, and yes it is the correct IP address – Jeremy Oct 20 '15 at 7:08
  • Are you passing in a URL to file_get_contents() or a file path? If it's on the same server, why are you not using a file path? – Ladadadada Oct 20 '15 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.