cURL returns 0 due to DNS error on SME Server

In my trials of getting Gallery and WordPress to interact on SME Server I discovered that I had not configured my DNS settings correctly.

If you use one SME Server then this will not be an issue. It will only arise in a multiple SME Server network and only if you are a bit slack, as I was, with setting the various hostnames.

In a single SME Server all the host names are setup automatically and you can add additional aliases for your server. This will never impact on cURL as when it is used the localhost DNS responds correctly.

In my case I have a second SME Server that is set up for my dev sites and is imaginatively called devsites as an alias. I set this up in the primary server hostnames for the same IP address as my dev sites server and as that worked for all the workstations in my network I promptly forgot about it.

As I worked with Gallery and WordPress plugins I found that cURL was not responding correctly and it took me a while to finally try using cURL at the command line on the server to establish the issue.

Testing cURL at the command line made it obvious.
[php]# curl -v http://devsites.mydomain/mysite/gallery/index.php[/php]
results in
[php]* getaddrinfo(3) failed for devsites.mydomain:80
* Couldn’t resolve host ‘devsites.mydomain’
* Closing connection #0
curl: (6) Couldn’t resolve host ‘devsites.mydomain’
[/php]

Obviously if cURL cannot resolve the host, the plugin will never work.

Adding the alias to the local machine meant that it would now resolve the DNS entry and cURL could do its lookup.

The specific gallery / wordpress plugin is Gallery3 Media Picker and I documented the specifics of what I did in the picker.php to provide support if cURL is not working in the appropriate thread in the Gallery 3 Forums.

One reply

Leave a Reply

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