Changing domain on Wordpress Ubuntu

I need to update the domain name for my website hosted through Digital Ocean.

I have the A records pointed to the new domain and the website displays, however when I run certbot, it only gives me the option for the old domain to generate a certificate.

My old domain is and my new one is just

Please advise what I need to do to fix this and update the domain.


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

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.

Hello, @harrywilson100

Are you hosting the site on a plain Ubuntu droplet or you have a control panel like cPanel/WHM installed as well? The process may vary with the different configuration.

If you simply have a LAMP/LEMP stack droplet you will need to update your virtual hosts and also rename the file for the domain name as well. The location of the vhosts on Ubuntu droplet is the following: /etc/apache2/sites-available and a symlink in the /etc/apache2/sites-enabled directory as well.

You can open the configuration file of the domain name and then change the lines that KFSys already mentioned:


Also to rename the file you can just use mv :


Then you can check the Apache configuration for any syntax errors using this command:

sudo apachectl -t

If you get Syntax OK you can go ahead and restart Apache with this command:

service apache2 restart

If you’re using Nginx the location of the configuration files is /etc/nginx/sites-available/ and the line you need to change in the file is the server_name and then you can again rename the file to match the new domain name.

Test your the configuration file for syntax errors by typing:

sudo nginx -t

You will also need to change the domain name in the WordPress installation as well. You can check this question that was previously asked in our community in order to do that:

Hope that this helps! Regards, Alex

Hi @harrywilson100,

First, you need to update your Apache configuration file and change the domain from to

Usually, you can find the apache configuration file in the /etc/apache2/sites-enabled/ folder. In those files you need to change the following lines;


Once you do, don’t forget to restart Apache. After those change certbot should be able to find the proper domain when it’s being called.

The next thing would be to update the database of your website. What I mean is, your database will contain references to the old domain. You’ll need to update it with the new one.