Two of the biggest risks, when switching web hosting or migrating a website to a new server, is data loss and downtime. Both issues can make your website temporarily inaccessible, which can result in loss of sales and search engine rankings.

However, if you follow our step-by-step guide, you can mitigate these risks and hopefully avoid making costly mistakes.

Good to Know: Many WordPress hosting companies offer a free migration service while some might charge a small fee. To find out, ask your new hosting company before attempting to make the move yourself.

However, if you want to learn the process yourself, these are the 7 steps you need to take.

  1. Choose a new WordPress host
  2. Setup the Duplicator Plugin for Easy Migration
  3. Import your WordPress site to the new host
  4. Change the Hosts file to prevent downtime
  5. Create a MySQL database on your new host
  6. Run Duplicator website migration script
  7. Update your domain name server

Step 1: Choose Your New WordPress Host

If you want to improve the speed of your web host even after optimizing WordPress speed and performance, you can move your WordPress site to a new host that can handle your traffic.

Your hosting options include:

  • Shared hosting
  • Cloud hosting
  • Location-specific providers
  • Managed WordPress hosting

After purchasing your new hosting, do NOT install WordPress. At this point in the process, your new web hosting account should be empty and have no files or folders in your main directory.

Step 2: Setup Duplicator for Easy Migration

Install and activate the free Duplicator plugin on the website that you want to move. Duplicator is a free plugin that can be used to move your website to a new domain name without loosing SEO.

Once you have installed and activated Duplicator, go to the Duplicator » Packages page in your WordPress admin area.

Next, you need to click the ‘Create New’ button in the top right corner.

Click the Next button and follow the steps to create your package.

Make sure that your scan results are clear (“Good”), and then click the Build button.

The process may take several minutes to complete, so leave the tab open as the plugin does its job.

Once the process is complete, download options for Installer and the Archive package will appear. Click on the ‘One click download’ link to download both files.

The archive file is a copy of your complete website, and the installer file will automate the installation process.

Step 3: Import Your WordPress Site to the New Host

After downloading both the archive and installer files you can upload them to your new web host by connecting to your new web host using FTP.

Usually, you enter your website’s domain name as host when connecting your FTP client. However, because your domain name is still pointing to your old host, you need to connect by entering your server’s IP address or server hostname. You can find this information from your new hosting account’s cPanel dashboard.

If you are unable to find this information, customer support for your new web hosting company should be able to supply the information.

Using the FTP client, you need to upload both installer.php file and your archive .zip file to the root directory of your website; such as /username/public_html/ folder.

Ensure that your root directory is completely empty. Some web hosting companies automatically install WordPress when you sign up, so you need to delete WordPress first if this is the case.

Once you’ve done this, upload the archive zip file and installer.php file to your site’s root directory.

Step 4: Change The Hosts File to Prevent Downtime

Once you’ve uploaded both files to your new host, you need to access the installer.php file in a browser. This file can usually be accessed using a URL like this:

http://www.example.com/installer.php

However, this URL will take you to your old web host, and you will get a 404 error because your domain name is still pointing to your old web host.

This is why you want to access your host’s file and avoid downtime. Your host’s file can be used to map domain names to specific IP addresses, so you trick your computer in thinking that the website is moved even though it’s not.

So you add an entry for your domain name in the host’s file so that it points to your new hosting company which allows you to access the files on your new host using your own domain name, while other site users still access your site from the old host ensuring no downtime.

First, find the IP address of your new web hosting server by logging into your cPanel dashboard and clicking on the ‘expand stats’ link in the left-hand sidebar. Your server’s address will be listed as Shared IP Address.

On some web hosting companies, you will find this information under the ‘Account Information’ heading.

Next, Windows users need to go to Programs » All Programs » Accessories, right-click on Notepad and select Run as Administrator.

A Windows UAC prompt will appear, and you need to click on Yes to launch Notepad with administrator privileges.

On the Notepad screen, go to File » Open and then navigate to the C:\Windows\System32\drivers\etc folder. From this folder, select the host’s file and open it.

Mac users need to open the Terminal app and enter the following command to edit hosts file:

sudo nano /private/etc/hosts

For both Windows and Mac users, at the bottom of the host’s file, you need to enter the IP address you copied and then enter your domain name. Like this:

192.168.1.22 www.example.com

Make sure that you replace the IP address with the one you copied from cPanel, and example.com with your own domain name.

Remember to save your changes.

You can now access your files on the new host using your domain name on your computer.

Remember: You need to undo the changes you made to the host’s file after you have finished the migration (step 6).

Step 5: Creating a MySQL Database on Your New Host

Before running the installer on the new host, you will need to create a MySQL database on your new hosting account. If you have already created a MySQL database, then you can jump to the next step.

Creating a Database in cPanel

Go to your new hosting account’s cPanel dashboard, scroll down to the Databases section and click on MySQL databases icon.

You will see a field to create a new database. Enter a name for your database, and click the “Create Database” button.

After creating a MySQL database, you need to scroll down to the MySQL Users section.

Next, provide a username and password for your new user and click on the ‘Create a user’ button.

Next, add this user to your database. This will give the username you just created all the permissions to work on that database.

You can do this by scrolling down to ‘Add User to a Database’ section. Select the database user you created from the dropdown menu next to the user, then select “Database”, and click on the add button.

Your database is now ready to be used with WordPress. Remember to record the database name, username, and password.

Step 6: Begin the Duplicator Migration Process

Now you’re ready to run the installer. Navigate to the following address in your browser window, replacing example.com with your domain name:

http://www.example.com/installer.php

The installer will run a few tests and will show you ‘Pass’ next to archive and validation tests.

You need to check the ‘terms & conditions’ checkbox if you agree and continue by clicking on the Next button.

Now, you will be asked to enter your MySQL host, database name, username, and password.

Your host will likely be localhost. After that, you will enter the details of the database you created in the previous step.

You can click on the ‘Test Database’ button to make sure you entered the correct information.

If Duplicator is able to connect, then you will see a string starting with Pass. Otherwise, you will see the database connection error details.

Click the next button to continue.

Duplicator will now import your WordPress database from the archive zip into your new database.

Next, it will ask you to update the site URL or Path. Since you are not changing domain names, you do not need to change anything, just click on the next button to continue.

Duplicator will run the final steps and will show you the login button.

You can now login to your WordPress site on the new host test that everything is working as expected.

Step 7: Update Your Domain Name Servers (DNS)

You’ve now created a complete copy of your WordPress database and files on your new hosting server, but your domain is still pointing to your old web hosting account.

To update your domain, you need to switch your DNS nameservers to ensure that your users are taken to the new location of your website when they type your domain into their browsers. If you registered your domain with your hosting provider, then it’s best to transfer the domain to a new host. If you used a domain registrar like Domain.com or GoDaddy then you need to update your nameservers.

You will need the DNS nameserver information from your new web host, which is usually a couple of URLs that look like this:

ns1.hostname.com

ns2.hostname.com

In this example, DNS nameservers with GoDaddy have been used.

Depending on your domain registrar or web host, the screenshots may look different. However, the basic concept is the same.

Find the domain management area and then look for nameservers. Your web hosting company can help to update nameservers.

For GoDaddy, you need to login to your GoDaddy account and then click on Domains.

Next, click on the Manage button next to the domain name you want to change.

Under the ‘Additional Settings’ section, you will need to click on ‘Manage DNS’ to continue.

Scroll down to the Nameservers section and click on the change button.

Switch the nameserver type dropdown from ‘Default’ to ‘Custom’ and fill in your new hosting provider’s information under Nameservers.

Click on the save button to store your changes.

After completing these steps you will have successfully changed the nameservers for your domain.

Remember, DNS changes can take 4 – 48 hours to propagate for all users. As you have the same content on your old host and your new host, your users wouldn’t see any difference. However, it is best to wait 7 days after your migration before canceling your old account just to be certain.