How to Move WP Site to New Hosting: Quick Answer Section
Can I move my WP website to new hosting myself?
Yes, as long as you have full administrative access (manage files and databases) to your current and new hosting, as well as to the domains DNS settings.
Do I need to use plugins to complete the migration?
Do I need server maintenance experience to move my site to new hosting?
No. It is all done on user-level.
How much time does the migration take?
The process itself takes up to an hour, depending on your internet connection, often just 15 min. The domain redirection can take up to 72 hours.
Can I expect downtime, when moving my site to new hosting?
Downtime can be completely avoided, as long as you keep your old website copy live, until the new one is in place and only redirect the domain after the site is up and running on the new hosting.
When should I close my old hosting account?
Only after the new hosting is set up and your site is moved. Some hosting providers close your account without warning upon making a request, even though you still may need to pay for the rest of your binding period.
Moving WP site to new hosting might seem so technical and almost impossible that you either give up on the idea or pay the new hosting provider to move your site. You might therefore be surprised to learn exactly how easy and fast it is to migrate to new server. It is indeed possible to move your site, without using any fancy programs or plugins, not even the popular Duplicator or ftp access.
This post will exemplify the process, using cPanel, the most popular server control panel. You can, however, follow the steps, described here and replicate them using any control panel that allows full file management (upload, download, zip, and unzip, as well database management are necessary). The procedure is always the same, only the exact names of for example file management or database management may vary).
Short Overview of Site Migrations
To make it easy for you, I am going to give you here an overview of the precise steps, needed to move WP site to new hosting. All the steps are thoroughly explained further down in this post.
- On the current server, zip all of your site’s files.
- Download the .zip archive
- Download a copy of your database
- On the new server, upload the .zip archive
- Create a new database
- Upload your old database into the new one
- Connect the database and the WordPress installation
- In the domain’s DNS settings, redirect your domain or do an A-forward
- If you in the same time migrate to a new domain, make sure to change it in your database.
- Check for errors
That’s it. In my experience, a site migration to a new host takes around a half an hour. The propagation of the domain takes though up to 72 hours.
Download the WordPress Files
To move WP site to new hosting, you must download all of the files in the directory, where your site is stored. Most often, this is the public_html directory. As long as the site you want to move is created under a subdomain/subdirectory or addon domain, the core directory isn’t public_html but (most often) a directory named after the subdomain/addon domain.
The files consist of WordPress’ core files (3 folders – wp-admin, wp-includes, and wp-content, and loose files) and possibly additional folders, containing complementing data and settings. You have to download them all. Here’s how you should proceed:
- Log into cPanel and navigate to File manager.
- In File manager, navigate to public_html or the subdirectory of your site.
- Click on public_html (or the respective directory of your site) to view its contents
- Select all of the folders and files in it by clicking on the first item, holding Shift (Windows) and clicking on the last item.
- After making sure that all items are selected, click on Compress in the top bar.
- In the popup window that appears, choose to compress as .zip and click on Compress File(s).
- Once the files are successfully compressed, a message appears to confirm that. Just remove the message.
- Next, select the .zip archive you just created and click on Download in the top bar.
- The .zip archive should now get saved on your computer. Make sure you know, where to find the file, when you’ll be using it later on.
Download the Database
In order for WordPress to function, it needs a database, where settings and changes get saved, looked up, and requested. WordPress cannot work without its database. Therefore, when you are about to move WP site to new hosting, you must also move the database.
To download the database, you need access to phpMyAdmin (or alternative database management). Here’s how you do it, step-by-step:
- From cPanel, navigate to phpMyAdmin
- Click on it to view a list of all the databases, connected to your account. As long as you just have one simple website, you probably have just one database. If you host more websites on the same account or host other applications, you will have more databases. Try to identify the database, connected to your site.
- If you aren’t sure, which is the database of your site, you can identify it by looking into the wp-config.php file. It is one of WordPress’ core files and maintains the connection to the database by storing the database name, user, and password. You can find the loose wp-config.php file in the same directory, where the three directories, wp-admin, wp-includes, and wp-content, are. Find the exact lines, shown in the screenshot below, and note down the characters between the ‘ ‘, after ‘DB_NAME’ (marked with red in the screenshot).
- Once you have identified the database, find it and click on it in the list of databases in phpMyAdmin
- Once you click on the database, you can see all of its tables. To export the whole database, you have to simply click on Export in the top bar.
- In the window that appears, choose Quick and then click on Go to download the database to your computer. The format should be SQL.
- Save the database and the WordPress files on your computer. This is all you need to do to get your files from your current server.
In the next section of this post, you’ll be guided step-by-step through the process of uploading WP site to new hosting and putting it live.
Move WP Website to New Hosting: The Upload
When moving WP site to new hosting, there are three steps to complete on the new server and one additional step to point your domain to the website:
- Upload WordPress’ core files
- Create a database and import your current one into it
- Connect the database to WordPress
- Redirect your domain or do an A-forward
It is completely up to you, which order you are going to do it in, what matters is that you complete all of the steps and that you don’t redirect the domain too soon. Redirecting the domain should indeed be done after completing all tasks on the new server and before closing your old hosting account to avoid downtime.
Upload WordPress’ Core Files to the New Server
To upload the WordPress files to the new server, you have to follow these simple steps:
- Log into your new hosting account’s cPanel and navigate to File manager, as you did in the first part of the process.
- Navigate to the folder, where you wish to upload WordPress. As long as this isn’t going to be an addon domain or subdomain installation, you have to upload the files into the public_html directory.
- Click on public_html to see its contents. Usually, it will either be completely empty or will contain a few files/folders with account settings. If, however, this is an account, where another website is hosted, you have to either remove the old files, move them to another folder or upload the new files to another folder. Do not upload WordPress core files to a directory, already containing a website. The risk of errors is too high.
- From within the public_html directory, click on Upload in the top bar
- Browse your computer and select the .zip archive you downloaded from your old hosting account.
- Once the .zip is uploaded, select it and click on Extract to unzip the files.
- It goes usually very quickly and you should now be able to see all of WordPress’ folders and loose files.
- To save disk space, delete the .zip file, once all files are unzipped.
That’s all you have to do with these files for now.
Upload the Database
Once WordPress is uploaded to the new hosting, you can continue by uploading the database. To do that, you have to do the following:
- In cPanel on the new server, navigate to the MySQL section. This is the section, where you can create new databases.
- On the MySQL Databases screen, locate the Create new database form and fill it out as shown in the screenshot below, where you choose a secure name for the database (random characters and numbers). Once ready, click on Create Database.
- Every database needs a user in order to allow access. Therefore, as the next step, locate the Add New User form further down the same screen. Enter a secure name and use the password generator to get a secure password. Remember to note down the database name, user, and password!
- Next, you have to add the user to the database. You do that on the very same screen (just click on Go back on the success-message screen), close to the bottom. You choose the database and user from the dropdown menus of the Add User to Database form. Click on Add, once ready.
- When you add a user to a database, you are prompted to choose, which privileges should be given to the user. In this case, you must give all privileges. Click on Make Changes, when ready.
- Now that the database is properly created, you can upload your current database into it. To do that, click on phpMyAdmin in cPanel as you did, when downloading the database, and select the newly created database to see its contents. It should be empty.
- Click on the Import button in the top bar.
- Browse your computer for the database file you downloaded from your current hosting account, leave the default settings as they are and click on Go. You only need to tweak these settings, if something goes wrong.
- Once the database is uploaded, a success message appears. When you click on the database name in the list to the left of the screen, you should see all of its tables. This is your database – in place and working.
- Only if you migrate to new domain: In the list of tables, click on wp_options. The prefix varies, depending on the settings, you chose, when installing WordPress. Once you click on the table, its content appears to the right. Find the values, marked in the screenshot and enter the correct values: exchange the current siteurl and home values with the new siteurl and home (they are for the most of it the same), change your email (admin_email), and the site’s name and description. In addition, you must run a search and replace to replace all instances of the old domain name with the new one in the database, once the migration is complete. To do that, you can use any search and replace plugin.
That’s it. Now you are ready to connect the database to WordPress.
Connect WordPress to the Database
Once all the files and the database are in place in your new hosting account, you have to connect WordPress to its database in order for it to work. You do that by following these steps:
- In cPanel, click on File manager.
- In the directory public_html, locate wp-config.php (loose file in the same directory as the directories wp-admin, wp-includes, and wp-content)
- Select the file and click on Edit in the top bar.
- You can disregard the warning that appears, as you do have the original file stored on your computer, should something go wrong.
- Find the following lines in the file:
- On the first line, ‘DB_NAME’, replace ONLY the text in red with the new database name (in your file, you’ll be seeing your current database credentials, the text in red is just an example). There shouldn’t be spaces between the appostrophes!
- On the second line, ‘DB_USER’, replace the text in red with the new database username.
- On the third line, ‘DB_PASSWORD’, replace the text in red with the new user password.
- The next line is ‘LOCALHOST’. Quite often, the value for this line is ‘localhost’ but you should always ask your hosting provider about the localhost, before you start the migration. Wrong localhost results in a database error.
- Save your changes.
Change the Domain’s DNS
As a part of moving your site to new hosting, you must change the DNS settings of your domain.
As long as you have access to the domain’s control panel, you should log in and change the nameservers (or the IP, if using IPs) of the domain. You should ask your new hosting provider about which nameservers you should point your domain to, as long as you didn’t receive that information in your welcoming letter.
If you use an external service for mails or don’t want to move your mails from your current hosting, you can point the domain to the new server by using an A-forward. This means basically that you change the value of the A-entry in the DNS records to the IP address of the new server.
It usually takes up to 72 hours tops for the domain to propagate. As long as all the site’s files are in place, both in the old and the new hosting, your site visitors won’t notice anything. You can confirm the redirection of the domain by checking its IP address via an online service such as IP checker.
Once you confirm the redirection, check your site for errors. Most of the time, everything should be fine but sometimes errors do occur.
Most common is the Error establishing a database connection, which is caused by entering a wrong value in one of the database credentials fields. If this happens, don’t panic. Just re-enter all the values by copy-pasting them to minimize the risk of errors and be careful to not include any spaces and not delete any characters.
Another common error is http 500 error, which is often caused by incompatible php version on the server or errors in the upload process due to php limitations. You can often change both the php version and php limitations yourself but if you find it difficult, contact your hosting provider. They should be able to help you.
Sometimes, you can experience that the site’s design is a bit screwed or that clicking on other URLs than the home page gives an error. These errors are easily resolved by simply going into the site’s design settings and clicking on Save and re-saving your permalink settings (Settings->Permalinks->Save).
Lastly, if you changed your domain name during the migration, errors can be caused by forgetting to run a Search & replace plugin to update the domain name in the database. Simply do it, once you discover errors.