Are you planning to move your WordPress site to a new hosting or another server? The biggest risk when changing hosting or migrating a site to another server is data loss and downtime.
Both can make your site temporarily unavailable to users and search engines, which can lead to lost sales and lower search engine rankings.
In this step-by-step tutorial, we'll show you how to safely migrate your WordPress site to new hosting without downtime.
You will also find answers to the most frequently asked questions related to moving a WordPress site to a new hosting, with the help of which you can avoid some common mistakes.
Important: Before continuing the text, it is useful to know that many hosting companies offer a free migration service. It may not be listed on their site, so the question needs to be asked. Usually this service is free, but with some you may pay a certain fee.
With that in mind, let's take a look at the steps we'll cover to move WordPress to a new hosting (without downtime)
1. Choose a new WordPress hosting
2. Install the Duplicator plugin for easy migration
3. Import your WordPress site to the new hosting
4. Edit the hosts file to prevent crashes
5. Create a MySQL database on the new hosting
6. Run the Duplicator script to migrate the site
7. Update your DNS
8. Frequently asked questions about moving WordPress to new hosting
Ready? Let's get started
Step 1: Choose a new WordPress hosting
If you're stuck with slow web hosting, even after optimizing your site, it's time to change your hosting provider.
When looking for a new hosting provider, it's important to choose carefully so that you don't have to change again soon.
After purchasing a new hosting, DO NOT install WordPress. We will do this in one of the following steps.
For now, your new web hosting account should be completely empty, with no files or folders in the main directory.
Step 2: Install the Duplicator plugin for easy migration
The first thing you need to do is install and activate the free Duplicator plugin on your site.
Duplicator is a free plugin that we highly recommend. You can also use it to move your site to a new domain without losing SEO.
However, in this article, we will walk you through how to use it to migrate your WordPress site from one hosting to another without any downtime.
After installing and activating Duplicator, go to the Duplicator » Packages page in your WordPress dashboard.
Next, you need to click on the 'Create New' button in the upper right corner.
After that, click the Next button and follow the further steps to create the package.
Be sure to check the scan results (everything should say Good) and then click the Build button.
The process may take several minutes, so do not disconnect the card until the plugin has finished its work.
Once the process is complete, you will see options to download the installation and archive package. You need to click on 'One click download' button to download both files.
The archive file is a copy of your entire site, and the installation file will automate the installation process for you.
Step 3: Import your WordPress site to the new hosting
Now that you've downloaded both the archive and installation files, the next step is to upload them to your new web hosting.
You can do this by connecting to your new web hosting using FTP.
Normally, when connecting an FTP client, you would enter the site's domain name as hosting.
However, since your domain name still points to your old hosting provider, you will need to connect by entering the IP address or name of your new hosting. You can find this information in the control panel of your new hosting account.
If you cannot find this information, you can ask your new web hosting provider for help and they will help you.
Using an FTP client, you need to upload both the installer.php file and your archive .zip file to the root directory of your site.
This is usually the /username/public_html/ folder.
Again, if you're not sure, ask your web hosting provider.
Make sure your root directory is completely empty. Some providers automatically install WordPress when they sign up.
If WordPress is installed in your root directory, you need to delete WordPress first. Once you've done that, you need to upload the archive zip file and the installer.php file to your site's root directory.
Step 4: Edit the hosts file to prevent crashes
After you have uploaded both files to your new hosting, you need to access the installer.php file in your 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 the old hosting and you will get a 404 error. This is because your domain still points to your old hosting. Usually, other tutorials might tell you to change your server domain name and point it to a new web hosting provider, but that's wrong.
If you do this now, visitors will see a broken site while you migrate it. We will show you how you can temporarily access your site on the new hosting on your computer without affecting the current site on the old hosting.
This is done with the hosts file on your computer.
The hosts file can be used to map a domain name to a specific IP address. In other words, it allows you to trick your computer into thinking that the site has been moved to another hosting when it still hasn't.
See how you can do this so it points to your new hosting.
By making these changes, it will allow you to access the files on your new hosting using your domain, while the rest of the world STILL accesses your site on the old hosting. This ensures 100% continuous operation of the site.
The first thing you need to do is find the IP address of your new hosting server. To find it, you need to login to your cPanel control panel and click on the expand statistics vase on the left sidebar. Your server address is located under Shared IP Address.
With some hosting providers, you can find this information under the heading Account Information
In the next step, Windows users should go to Programs » All Programs » Accessories, then right-click Notepad and select Run as Administrator.
A Windows UAC prompt will appear and you need to click Yes to open 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 hosts file and open it.
If you're using a Mac, you need to open the Terminal app and enter this command to edit the hosts file:
sudo nano /private/etc/hosts
For both Windows and Mac users, at the bottom of the hosts file, you must enter the IP address you copied and then the domain name:
192.168.1.22 www.example.com
Be sure to replace the IP address with the one you copied from cPanel and example.com with your domain.
When you're done, save your changes.
Now you can access the files on the new hosting on your computer using your domain.
Important: Don't forget to undo the changes you made to the hosts file after the migration is complete (step 6).
Step 5: Create a MySQL database on the new hosting
Before you run the installer on your new hosting, you need to create a MySQL database on your hosting account. If you have already created a database, then you can proceed to the next step.
Creating a database in cPanel
Go to the cPanel control panel in your new hosting account, scroll to the Databases section and click on the 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 the My SQL database, you need to scroll to the MySQL users section.
Next, provide a username and password for the new user and click the Create a user button.
After that, you need to add this user to your database. This will give the username you just created all permissions to work on that database.
You can do this by scrolling down to the Add User to a Database section. Simply select the database user you created from the drop-down menu, then select the database and click the Add button.
Your database is now ready to use with WordPress. Be sure to note the database name, username, and password. You will need that information in the next step.
Step 6: Run the Duplicator script to migrate the data
You are now ready to run the installer. Navigate to the following address in a browser window:
https://www.example.com/installer.php, where you type your domain instead of example.com.
The installer will run several tests and show you a Pass in addition to the archive and validation tests.
You must uncheck the terms&conditions checkbox and continue by clicking the Next button.
Now you will be asked to enter your MySQL hosting, database name, username and password.
Your hosting will probably be localhost. You will then enter the details of the database you created in the previous step.
You can click on the Test Database button, to make sure that you have entered the correct data.
If the Duplicator is able to connect, you will see a string starting with Pass. Otherwise, you will see the details of the database connection error.
Click the Next button to continue.
Duplicator will now import your WordPress database from the archive zip into your new database.
You will then be prompted to update the URL or site path. Since you are not changing the domain name, you don't need to change anything here.
Simply click the Nex button to continue.
Duplicator will run the final steps and show you the Login button.
You can now log into your WordPress site to make sure everything is working as you expect.
Step 7: Update your DNS
At this point you have created a complete copy of your WordPress database and files on your new hosting server, but your domain STILL points to your old hosting.
To update your domain, you need to change your DNS server name. This ensures that your users are redirected to your site's new hosting when they type your domain into a browser. If you have registered the domain with your hosting provider, then it is best to transfer the domain to a new hosting. If you've been using a domain registrar like Domain.com, GoDaddy, and the like, you need to update your DNS.
You will need DNS name server information from your new hosting. These are usually several URLs that look like this:
ns1.hostname.com
ns2.hostname.com
For the purposes of this tutorial, we will show you how to change your DNS server name using GoDaddy.
Depending on the domain registrar or web hosting, the printscreens may look different. However, the basic concept is the same.
You need to look for the domain management area and then look for the server name.
For GoDaddy, you need to login to your GoDaddy account and then click on Domains. After that, you need to click the Manage button next to the domain name you want to change.
In the Additional Settings section, you need to click on Manage DNS to continue.
Next, you need to scroll down to the Nameservers section and click the Change button.
First, you'll need to change the Server Type drop-down menu from Default to Custom. After that, you can fill in the information about the new hosting provider under Nameservers.
Don't forget to click the Save button to save your changes.
You have successfully changed the server name on your domain. DNS changes can take 4 to 48 hours to change for all users.
Since you have the same content on both your old and new hosting, your visitors won't see any difference.
To be on the safe side, we recommend that you wait until 7 days after site migration to cancel your old hosting account.
Frequently asked questions about moving WordPress to new hosting
Here are some questions that many of our users ask when moving WordPress from one hosting to another.
1. Can I sign up for new hosting without registering a domain name?
Yes, you can absolutely sign up for new hosting without registering a domain name.
Domain name and hosting are two different services and you don't necessarily need to register a domain name when signing up for new hosting.
Some hosting providers will ask you to choose a domain name as the first step when purchasing hosting. It will also allow you to enter a domain name if you already have one.
2. Should I transfer my domain to new hosting?
No, you don't need to transfer your domain to a new hosting. However, transferring your domain to new hosting will make it easier for you to renew and manage it in the same control panel as your new hosting account.
3. How do I fix the database connection error in Duplicator?
If you see a database connection or database error in Duplicator, the most likely reason is that you entered incorrect database connection information.
Make sure the database name, MySQl username and password are correct.
Some hosting providers do not use localhost as hosting for their MySQL servers. If this is the case, ask them for help in providing you with accurate information.
4. How can I check if my site is loading from the new hosting?
There are several tools on the Internet that allow you to see who is hosting a site. After you move your site to new hosting, you can use any of these tools and they will show you the name of the hosting provider that hosts your site.
If it hasn't been long since you migrated the site and made DNS changes, it's likely that the site can still be loaded from the old hosting. DNS changes can take up to 48 hours to fully propagate.
5. Do I need to delete files or data from the old hosting?
When changing hosting providers, we recommend that you keep the old hosting for at least another week. After that you can delete the files from the old hosting. If you cancel your account, the hosting provider will delete all your data in accordance with its policy.
6. How long should I keep my account active on the old hosting?
After you migrate your site to the new hosting and if you don't have any other sites hosted with the old provider, you can cancel your old hosting account.
However, in some cases you may have already paid for their annual hosting. In that case, you should check their cancellation refund policy.
7. How do I move a WordPress site with SSL/HTTPs?
You will need to install an SSL certificate with your new hosting provider. After that, you can follow the same steps mentioned above. Be sure to use HTTPs in URLs, for example https://example.com
We hope that this tutorial was useful for you and in case you have additional questions about hosting, domains, sites, you can contact us at this link, to get answers to your questions.
Text taken from wpbeginner.