All HowTo's Web Servers

Solution to “Cannot connect to self over HTTP — possible DNS resolution issue.”

If you get the error message as follows or similar to it, this article is for you.

One or more HTTP connection tests failed against localhost.
Cannot connect to self over HTTP — possible DNS resolution issue.
Can't connect to:

In order to run s2Member, your installation of PHP needs one of the following...
• Either the cURL extension for remote communication via PHP (plus the OpenSSL extension for PHP).
• Or, set: allow_url_fopen = on in your php.ini file (and enable the OpenSSL extension for PHP).
Please consult with your web hosting company about this message. See also: WordPress recommended hosting platforms.

On the server that i found this trouble on, everything is correct according to the recommendations seen in the error message above. The Apache logs show:

[Wed Jan 17 18:02:52.023766 2018] [:error] [pid XXXXXX] [client XXXXXX] PHP Warning:  file_get_contents( failed to open stream: No route to host in

So test it with “ping” and it will return a result. Test it with “telnet 80” or “telnet 443” and you’ll get the above error.

The solution is to add the following to your “/etc/hosts” file which tells Apache not to go out to the network to find the host:

If that’s not it, it might be that the recommended solution (mentioned in the error at the start of this article) could be it.

First check your PHP version:

php -v

Returns something like “PHP 5.6.32”.

The command:

php -r "phpinfo();" | grep -i openssl

shows something like “OpenSSL support => enabled”.

The “/etc/php.ini” file shows “allow_url_fopen = On”.

Curl support should be fine. The “php56w-common” package contains the curl extensions.

Leave a Reply

Your email address will not be published. Required fields are marked *