How to Migrate a Website (Changing Hosts)
How to migrate a website with no downtime: file and database backups, uploading to the new host, testing with the hosts file, DNS, email and WordPress.

Contents
- Before you migrate: preparation
- Step 1: Back up the old hosting
- Step 2: Prepare the new hosting
- Step 3: Upload the files and database
- Step 4: Update the configuration file
- Step 5: Test without changing DNS
- Step 6: Point DNS to the new hosting
- Step 7: SSL and final checks
- Moving email
- Migrating a WordPress site
- Migrating your site to Nodesty
Migrating a website means copying a site's files and database from the old host to the new one and pointing the domain to the new server. Done in the right order, your visitors won't notice any downtime: you first copy everything to the new server, test the site without changing DNS and only point the domain to the new server once everything works.
This guide covers every step of migrating a website with no downtime, from preparation and backups to moving files and databases, testing with the hosts file, changing DNS and moving email.
Before you migrate: preparation
A good migration starts with a checklist made before you begin:
- Decide what you're moving. Site files, databases, email accounts, scheduled tasks (cron) and subdomains.
- Note the technical requirements. PHP version, required PHP extensions, database type and version. Choose the same or a compatible PHP version on the new host.
- Take a copy of your DNS records. Especially the A, CNAME, MX and TXT records. When you change nameservers, these records don't carry over to the new location on their own.
- Lower the TTL. At least a day before the migration, lower the TTL of your domain's A record to 300 seconds (5 minutes). That way the DNS change propagates within minutes.
- Pick a quiet time. Migrating during your lowest-traffic hours reduces the risk of losing content that changes in the meantime.
Step 1: Back up the old hosting
Every website has two parts: files and a database. Back up both.
Files: In cPanel, compress the public_html folder in the File Manager (Compress) and download it. In DirectAdmin, you do the same from the file manager. If there are a lot of files, downloading a single compressed archive is much faster than using FTP.
Database: In phpMyAdmin, select the database and download it as a .sql file from the Export tab. If you have SSH access:
mysqldump -u username -p database_name > backup.sql
If both the old and the new host use cPanel, taking a Full Account Backup is the most practical route. This backup bundles files, databases, email accounts and settings into a single archive, and you can ask the new provider to restore it.
Step 2: Prepare the new hosting
- Create the new hosting account with your domain.
- Select the PHP version your site needs in the control panel.
- Create a new database and database user, and give the user all privileges on the database.
On shared hosting, your account name is added to the start of database names and usernames (such as account_wpdb). Note down these names and the password; you'll need them in step 4.
Step 3: Upload the files and database
- Files: Upload the archive you downloaded to the
public_htmlfolder with the new host's file manager and extract it there (Extract). You can also use FTP, but uploading a single archive and extracting it on the server is much faster than sending thousands of small files one by one. - Database: In the new host's phpMyAdmin, select the database you created and upload the
.sqlfile from the Import tab.
Step 4: Update the configuration file
The site uses a configuration file to connect to the database. In WordPress, this is the wp-config.php file:
define( 'DB_NAME', 'account_wpdb' );
define( 'DB_USER', 'account_wpuser' );
define( 'DB_PASSWORD', 'new-password' );
define( 'DB_HOST', 'localhost' );
In Laravel it's .env, and in other software it's usually config.php or a similar file. Match these details to the database you created in step 2.
Step 5: Test without changing DNS
This is the secret to a migration with no downtime. By adding a line to your computer's hosts file, you make your domain point to the new server on your computer only:
- Windows:
C:\Windows\System32\drivers\etc\hosts(open Notepad as administrator) - macOS and Linux:
/etc/hosts
203.0.113.10 yourdomain.com www.yourdomain.com
Replace 203.0.113.10 with the new host's IP address. Clear your browser cache, open the site and check everything: pages, images, forms, logging in to the admin panel and, if you have them, checkout steps. Don't forget to delete the line you added once testing is done.
Step 6: Point DNS to the new hosting
If everything works, point the domain to the new server. There are two ways:
- Changing nameservers: You replace your domain's nameservers with the addresses the new host gives you. Set up your old DNS records (especially MX and TXT) in the new panel first.
- Changing only the A record: The nameservers stay where they are, and you update the A record to the new IP address. This is the safer route if your email is hosted elsewhere.
We explain how DNS records work in What is DNS? and how to connect your domain to your hosting in What is a domain name?
Step 7: SSL and final checks
Once DNS points to the new server, enable the SSL certificate on the new hosting; free certificates need DNS to point to the new server for domain validation. Then:
- Check that the site opens with
https://and the browser shows no warnings. - Re-create your scheduled tasks (cron) on the new hosting.
- Send a test email from your contact forms.
- Watch Google Search Console for errors for a few days.
Don't close the old hosting right away. The DNS change may reach some visitors late. Keep the old account open for at least a few more days.
Moving email
Email is the part most often forgotten in a migration:
- List the email accounts on the old hosting.
- Create the same accounts at the new location.
- Update your MX, SPF, DKIM and DMARC records for the new provider. For details, see SPF, DKIM and DMARC explained.
- Move your old emails over IMAP. You can add both accounts to the email client on your computer and drag the folders across, or use a tool such as
imapsync.
Keeping your email independent of your website removes this step entirely the next time you change hosts.
Migrating a WordPress site
You can migrate WordPress manually with the steps above or use a plugin:
- With a plugin: All-in-One WP Migration or Duplicator turns the site into a single package. You install a fresh WordPress on the new host and import the package with the same plugin. Some plugins have file size limits in their free versions.
- If the domain changes: WordPress stores the site address in many places in the database. To replace the old address with the new one, use a plugin such as Better Search Replace or, if you have SSH access, the
wp search-replacecommand. Don't run a plain find-and-replace directly on the database; serialized data can break.
After the migration, opening and saving Settings → Permalinks often fixes links that return 404 errors. If you're installing WordPress for the first time, take a look at our WordPress installation guide.
Migrating your site to Nodesty
Nodesty web hosting plans come with a choice of cPanel or DirectAdmin. You can upload your files with the file manager or FTP and import your database through phpMyAdmin; with the LiteSpeed web server, NVMe storage, free SSL and JetBackup backups, your site is fast and safe from the first day after the move. If you want to keep your email independent of your site, our mail hosting plans make sure your email isn't affected at all the next time you change hosts.
Frequently Asked Questions
Does my website go down during a migration?
Not if you do things in the right order. The old hosting stays up until the DNS change has fully propagated; during that time visitors see the same site on either the old or the new server. The key to avoiding downtime is to close the old account a few days after the DNS change.
How long does a migration take?
Moving the files and database of a small site usually takes less than an hour. Most of the time goes into DNS propagation; if you lowered the TTL beforehand, this drops to a few minutes, otherwise it can take anywhere from a few hours to a day.
Do I need to transfer my domain too?
No. Your domain can stay with its registrar; you only need to point the DNS records or nameservers to the new host. A domain transfer is a separate, optional process.
Will I lose emails during the migration?
If your email is on the old hosting and you only change the nameservers, new emails won't arrive unless you set up the MX records at the new location. Note down your MX records before migrating, create the mailboxes at the new location and move your old emails over IMAP.
Can I migrate a WordPress site with a plugin?
Yes. All-in-One WP Migration, Duplicator and similar plugins export your files and database as a single package and import it on the new site. On large sites, plugins may have file size limits; in that case, migrating manually is more reliable.
My site opens after the migration but shows a database error. Why?
Errors such as Error establishing a database connection are usually caused by the database name, username or password in the configuration file not matching the ones on the new host. Remember that on shared hosting, the account name is added to the start of database names and usernames.
About the author
Nodesty Team · Infrastructure & Support
The Nodesty team runs our servers, network and DDoS protection day to day and answers customer support requests around the clock. These guides come from that work.
Related articles

What Is a Subdomain and How Do You Create One?
What is a subdomain and how do you create one? Subdomains with DNS records, creating one in cPanel and DirectAdmin, pointing it to a game server, and SSL.

What Is Bandwidth and Traffic? Calculate Your Needs
What is bandwidth, and how does it differ from traffic? Mbps vs. MB/s, port speed, unlimited traffic, sizing for websites and game servers, and monitoring.

How to Change the PHP Version and php.ini Settings
How to change PHP version: choosing a version in cPanel and DirectAdmin, upgrading safely, and php.ini settings like memory_limit and upload_max_filesize.