NS DNS records
Start by examining the NS records for the domain. I use dig
on the command line, but you can also use versions of it online.
$ dig NS example.com
;; ANSWER SECTION:
example.com. 0 IN NS a.iana-servers.net.
example.com. 0 IN NS b.iana-servers.net.
You should see between 2 and 4 NS records for your domain. They are usually subdomains of your DNS hosting company. If you see old NS records or records other than what your DNS host has given you, then you have a problem that you need to fix. You can edit your NS records at your domain registrar.
A and CNAME records
Next examine the A and CNAME records for your base domain and the www subdomain at each of your name servers.
$ dig @a.iana-servers.net example.com
;; ANSWER SECTION:
example.com. 86400 IN A 93.184.216.34
$ dig @a.iana-servers.net www.example.com
;; ANSWER SECTION:
www.example.com. 86400 IN A 93.184.216.34
$ dig @b.iana-servers.net example.com
;; ANSWER SECTION:
example.com. 86400 IN A 93.184.216.34
$ dig @b.iana-servers.net www.example.com
;; ANSWER SECTION:
www.example.com. 86400 IN A 93.184.216.34
For most sites, each query should have exactly one record. Having multiple IP addresses for a website is possible if you have have multiple servers that all serve the exact same content. However, if you don't have multiple servers and don't use a CDN, having multiple IP addresses is a mistake that can lead to your problems.
Similarly, each DNS name server should return the same records for your site. If one of them is returning something different, that can cause the the problems you describe.
Test the site
For each of your IP addresses, connect to your site on that IP address for all combinations of http/https and www/no-www. I use curl for this type of debugging.
$ curl --resolve example.com:80:93.184.216.34 --head http://example.com/
HTTP/1.1 200 OK
Content-Length: 648
$ curl --resolve www.example.com:80:93.184.216.34 --head http://www.example.com/
HTTP/1.1 200 OK
Content-Length: 648
$ curl --resolve example.com:443:93.184.216.34 --head https://example.com/
HTTP/1.1 200 OK
Content-Length: 648
$ curl --resolve www.example.com:443:93.184.216.34 --head https://www.example.com/
HTTP/1.1 200 OK
Content-Length: 648
Make sure that each of your URLs returns the correct status codes. For most sites, I would expect three of those four URLs to redirect. Take note of any connection errors or security certificate problems that you encounter.
If your site has multiple IP addresses, each IP address should return the same content using this method.