Figuring out how to switch web hosts can be a daunting task. There is a number of reasons why you should, though.
Where you host your website influences many things – security, site speed and backups. Additionally, there are many types of web hosting and you need to make sure you pick the right one for your needs.
If your current provider no longer fulfills them, it’s time for a change.
How do you move your site from one host to another? That’s exactly what we will talk about in this review.
Ready? Then let’s get going!
Gather Your Resources
To make the switch from one web host to another, you will need the following:
- Access to both hosting accounts — During the process you will have to make some changes to both your old and new hosting account. If you are not sure about your login credentials for either, now is the time to find out.
- Access to your database — Moving from one web host to another requires access to your website’s database. This often happens in the administration area of your hosting account, which means that there is one more reason to make sure you know how to get there.
- FTP client — Every case we are discussing below, requires moving data from or to an FTP server. For that you need an FTP client. A great free option is FileZilla but you can use any client of your choice.
- Text editor — You also need a code editor to modify important files. One of the best options is Notepad++ (it’s also free) but you can go with whatever you want.
Got everything together? Cool, then let’s jump right into how to switch web hosts for your WordPress site.
Moving Your Site from One Host to Another Manually
We will start off with doing the switch manually. If you are looking for a solution that uses a WordPress plugin, simply scroll down further.
1. Back Up Your Files
The first thing to do is to back up your website files. This will likely take the longest time, so let’s start with that. Step one is logging into your FTP server. Simply fire up the FTP client we talked about, insert your credentials and connect.
After that, find the root directory of your WordPress site (if it’s not your landing page by default) and mark all the files.
Note that your website might contain files that are not visible by default (such as
.htaccess). Therefore be sure that your FTP client displays those files as well. In FileZilla, you will find this option under Server > Force showing hidden files.
Once you have marked all files, copy them to a directory on your computer. Depending on the size of your site, this might take a while so we can move to step two meanwhile.
2. Export the Database
The database is the second part of your website. The way you get access to it differs from host to host. In most cases you end up in phpMyAdmin:
Select the database you want to export from the left. If you don’t know which one that is, simply check the
wp-config.php file of your current website where it says:
This will tell you the name of the database your site is using.
After that, go to the Export tab.
Choose Custom under Export Method. In the menu, make the following choices:
- Format — Leave as SQL.
- Tables — Mark all the tables you want to export. Usually, it’s all of them. Disable any if you have a good reason for that (e.g. if you host databases for several sites with different prefixes).
- Output — Set Compression to zipped or gzipped to make the download faster.
- Format-specific options — Leave everything as is.
- Object creation options — Make sure to select Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT / TRIGGER.
- Data creation options — Leave everything as is.
When you are done, click Go at the bottom. This should result in a file download. Save the compressed database to your computer and move on to the next step.
3. Create a Database at Your New Host
Now it’s time to create a new home for the database you just exported. Go to your new host and log into your account. Find the section that deals with MySQL databases.
Create the following:
- A new database
- A database user with full privileges to that database
- A secure database user password
Note down all three, you will need them soon. Also, find out the name of your MySQL server. In many cases, this will be localhost but check with your hosting provider to be sure.
4. Edit Config.php
By now your website files should have finished downloading. If that is the case, it’s time to go to the directory where you saved them and find a file called
It’s an important system file that, among other things, controls the communication between your website’s file system and the database.
The first thing you should do is to make a copy of the existing file and store it somewhere safe. After that, open the original with your text editor and find the following section:
define('DB_NAME', 'database_name_here'); /** MySQL database username */ define('DB_USER', 'username_here'); /** MySQL database password */ define('DB_PASSWORD', 'password_here'); /** MySQL hostname */ define('DB_HOST', 'localhost');
Replace where it says
username_here and password_here with the database name, username and password you created earlier. Note, that in your case it won’t actually say
database_name_here etc, but will contain the information of your current host. Those will be in the same position.
Additionally, make sure you insert your MySQL server information in the place of
localhost (or leave it as is if your hosting provider uses
localhost for this setting). When you are done, save the file.
5. Upload Your Files to the New Host
Once all of that is finished, you can start the process in reverse direction. The first step is to upload your files to the server at your new hosting provider. It will likely take a long time so we can start it and do other things while it’s running.
By now you know the drill. Fire up your FTP client and this time connect to the new server. A quick caveat: Usually you would use the site URL in order to connect via FTP. In this case, the domain is still pointing to your old server, so it won’t work.
There is a workaround, which is using the IP address of your new server instead. You can usually find this in your hosting account. If not, be sure to contact support – they should be able to help you out.
When you are done, find the files you downloaded earlier and upload them (including the modified
config.php file) to the root directory. Once the upload is running, move on to the next step.
6. Import the Database
Meanwhile, we can take the time to import the database. For that, log into the database administration tool on your new server. We will assume it is phpMyAdmin again.
Select the database you created earlier from the list and pick Import at the top of the screen.
Click the Browse button and select the file you exported earlier. After that, scroll down to the bottom and click Go. The import will then start.
The time it takes to finish depends on the size of your database. You will receive a success message when it’s done.
Optional: Replace the Old URL in the Database
If you are not only moving your site over to a new web host but also changing your URL, there is one extra step. In this case, you need to replace references to your old URL in the database with the new one. If you don’t, all sorts of things will go wrong!
There are several ways to do this. The easiest I have found is the Search Replace DB script. You can download it for free (in exchange for your email address). Just upload it to your website directory (in a secret folder) and navigate there using your browser.
Simply insert your old and new URL in the fields on top. Everything else should usually stay as is. Use the dry run button to test everything. When everything looks good, do the live run.
Important: Under no circumstances should you leave the script on the server once you are done. It’s very powerful and can do real damage to your site if someone else finds it.
Should the script not work for you, you can also replace the URL via SQL commands.
7. Change Your DNS Server
When you are done with all of the above, it is time to put your URL on the new server. That means changing your DNS server settings.
The process depends on where your domain is registered. For example, if you registered with your old hosting provider, the best idea is to transfer the entire domain to the new provider. Talk to the support about how to do that.
If you have bought it from a domain registrar like Namecheap, you need to update your nameserver settings. You will need the nameserver addresses of your new host. They usually look something like this:
You will have to connect these with your domain. As mentioned, the process will be slightly different depending on where you have purchased it. Here are instructions for some of the most common cases:
- Domains Registered with GoDaddy
- Changing DNS Servers on HostGator
- How to Change Nameservers on Namecheap
Talk to whoever is in charge if you need help. Once done, be aware that it can take up to 48 hours for the changes to happen. You can use a tool like What’s My DNS to see if it has finished.
Until then, be sure not to make any changes to your site. You may be modifying the old website instead of the new location.
Once everything is through, your site should be migrated without any downtime. Because both of your sites have the same content, visitors will not notice the change.
8. Cleaning Up
Once the DNS change has gone through, you can go back to your old host and delete your site files and database. You may want to wait up to a week before doing so to make sure everything works well.
In any case, be sure to keep your local copies (including the original
wp-config.php) around. There may be a need to roll back the migration. In that case, you’ll be happy you still have them.
How to Switch Web Hosts via WordPress Plugin
All of the above can be greatly shortened by using a plugin. It allows you to automate parts of the process. While there are other options out there, I greatly recommend the Duplicator plugin. It’s free and makes the process a breeze.
1. Install Duplicator
Naturally, the first step is to install the plugin. This requires the usual steps. Log in your WordPress website and navigate to Plugins > Add New. Type the plugin’s name into the search box to find it and click Install Now once it appears on the list.
When your site is done downloading, hit the Activate button to be able to use the plugin.
2. Export the Existing Site
Once Duplicator is installed and active, you will find a new menu item with its name in your WordPress admin area. Clicking it brings you to this:
The plugin saves its so-called packages. These are zipped up versions of your website and database. Since you haven’t created any yet, the list is empty. Time to change that. Click Create New in the upper right corner to get going.
In the next screen, you have several options.
- Storage — You can configure where to store your site back-up. Be aware that unless you have the Pro version of Duplicator, your only option is your own server so there is nothing to do here.
- Archive — In this section you may exclude both files and parts of the database from being migrated. Use this if you have good reasons.
- Installer — You can fill in the database information of your new server environment. This is also part of the later set-up so you can ignore it for the moment.
Most likely, you will simply click Next. The plugin will then perform a system check to see if it has everything it needs to run properly. You can see the findings once it’s done.
If everything is fine, start the build process by clicking the button at the bottom. This may take several minutes so don’t close your browser. When it’s finished, you will see this:
Download both the installer and archive by clicking the buttons separately or with the one-click download link. Well done!
3. Upload the Files via FTP
The next step is uploading those files to the server. You will need to use the IP address rather than the domain to connect via FTP.
Once connected, make sure that you upload both the installer file and the archive. Place them in the root directory and make sure it’s empty beforehand.
4. Create a New MySQL Database
With the plugin method, you will also need a MySQL database for your new site. We have talked about it in detail earlier. Do what you have to do in order to end up with a new database, a username with full privileges for the database and the database password. Be sure to note down the MySQL server your host gives you for your website.
5. Connect to the New Website
For the next step, you might be running into a problem. To deploy the site, you need to access the files on your server via a web browser. That usually happens by typing in the domain name.
If you are using the same domain as before, it is not pointing to your new server yet. Of course, you could change that to get around the problem. However, this would a) take a while to actually happen and b) will mean downtime for your site.
Luckily, there is a way around, which is using your computer’s hosts file. You can locally map domain names to specific IP addresses. That way, you are able to access files on the new server via the old domain without changing anything for your visitors.
(If you are using a different domain on your new host, you can skip this step completely.)
The first thing you need is the IP address of your new server. Your provider should display that information for you. If you can’t find it, ask!
After that, you need to open your hosts file. Here’s how to do that on different platforms:
- Windows — Open the taskbar menu, search for “notepad”. Right-click the result and choose “run as administrator”. Once running, use the program to open
c:\windows\system32\drivers\etc\hosts. Make sure you search for “All Files” in order to see the file in question.
- Mac OS — Open the terminal and enter the command
sudo nano /etc/hosts. You might be asked to enter your administrator password.
- Linux — For Linux you can use the same method as with Mac OS.
Once you have access to the file, you need to insert both the IP address you found earlier and the domain name. It will end up looking like this:
Note: the space between the IP address and the domain is a tab. Also, be sure to replace the address with your server’s actual address and yoursite.com with your real domain. Save the changes and you should be able to access the new server using your existing domain name.
Important: Once you have finished the migration, be sure to change your hosts file back to its original state!
6. Run the Migration Process
Now it’s time to start the migration process in earnest. Navigate to http://yoursite.com/installer.php (insert your actual domain), this should lead you to this screen:
Make sure the installer gives you a Pass for archive and validation, then check the terms and conditions box and click Next at the bottom. This will start the deployment process.
After that, you will be asked to insert your database host, name, username and password.
You should have those at hand from before. You can use the Test Database button to make sure everything is working. Then click Next again. The plugin will import the database.
In the next step, you have the chance to replace mentions of your old URL with the new one. Make sure the right URL is in the field! Duplicator will then finalize the process.
The final screen gives you a link to log into your site and reports if everything went well. Make sure to log in and check if everything is working as it should. Also, don’t forget to follow Duplicator’s instructions to clean up after yourself.
7. Update the DNS Nameserver
With this method, you still need to change your domain from your old server to the new.
We have already talked about this in detail above, so you can refer to that section. Get the nameserver addresses from your new host and connect them to your domain. Then wait until the changes have gone through before making changes to your site.
After that, you are done – congratulations! You have just learned how to switch web hosts for your WordPress website. Awesome sauce!
Switching Web Hosts for WordPress Websites in a Nutshell
Switching your WordPress site from one web host to another can be an intimidating task, especially for the first-timers. Keep in mind that just like everything else concerning running your own website, it becomes less difficult when you break it down to steps.
If you have followed along with the above, you should now have successfully moved your site to your new hosting provider. Whichever process you decided on, let’s quickly summarize the basic steps:
- Back up your website files and database
- Prepare the new hosting environment for the switch
- Import your files and database to the new host
- Switch the nameserver of your domain
That’s basically it. Congratulations again for making it this far – well done!
Do you have questions or additional tips on how to switch web hosts? Let us know in the comments section below.