0curl: (6) Could not resolve host: mydomain.com after Redirect non-www to www with Nginx

December 4, 2018 1.7k views
Nginx DNS Ubuntu 18.04

I’ve followed a tutorial post about redirect on Digital Ocean’s community.

But things didn’t worked for me as in the tutorial.

Below is my server block code for redirect from config file /etc/nginx/conf.d/redirect.conf:

server {
    server_name www.crusadehimalaya.com;
    return 301 $scheme://crusadehimalaya.com$request_uri;
}

I’ve also added A record with “www” ** and **@

Running curl -I http://www.crusadehimalaya.com
gives the following response

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   194    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
HTTP/1.1 301 Moved Permanently
Server: nginx/1.14.0 (Ubuntu)
Date: Tue, 04 Dec 2018 07:45:15 GMT
Content-Type: text/html
Content-Length: 194
Connection: keep-alive
Location: http://crusadehimalaya.com/

Running curl -I http://crusadehimalaya.com
Gives following output:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: crusadehimalaya.com

1 comment
1 Answer

It’s most likely due to a DNS propagation issue. I’m getting good output now. So perhaps the issue you were facing subsided as propagation completed.

Cheers

Have another answer? Share your knowledge.