How can I stop my domain from displaying the IP address?

I’ve read countless questions and answers almost identical to my problem but cannot figure this out. Environment is Apache 2.4.6 on CentOS 7.4.

I have my nameserver records with DO: A points to my droplet CNAME www points to

Either of those addresses loads my site. If I use the www prefix, then that domain remains in my browser location bar. If I use the one without www then the location switches to the IP address.

My virtual host config is as follows:

<VirtualHost *:80>
    DocumentRoot /var/www/
    ErrorLog /var/log/httpd/
    CustomLog /var/log/httpd/ combined

I originally had the ServerName and ServerAlias around the other way but the result was the same.

At this stage I have a simple, static HTML page for testing. There’s a WordPress install waiting in the wings, and I know about the settings there (because I’ve stuffed them up on several occasions before on shared hosts :-) ). I’ve verified there is no .htaccess file in the document root for this virtual host.

I’m sure I’m missing something simple, but I cannot figure out what.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Solved! The issue was Safari (macOS) caching the DNS entry from prior to the config changes.

I flushed the DNS cache with the following command on macOS 10.13 High Sierra (should also work on 10.12 Sierra).

sudo killall -HUP mDNSResponder

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel