Migrating a WordPress website using SFTP is one of the safest ways to move your site files from one hosting provider to another. SFTP stands for Secure File Transfer Protocol. It allows you to securely upload and download website files between your computer and your hosting server.
A full WordPress migration usually has two main parts:
-
Moving the WordPress files using SFTP
-
Moving the WordPress database using phpMyAdmin or another database tool
This guide explains how to migrate your WordPress website using SFTP step by step.
⸻
What You Need Before Starting
Before you begin, make sure you have the following:
-
SFTP login details for your old hosting account
-
SFTP login details for your new hosting account
-
Database access for the old website
-
Database access for the new hosting account
-
A file transfer app such as FileZilla, Cyberduck, or WinSCP
-
Access to your domain DNS settings
Your SFTP details usually include:
-
Hostname or server IP address
-
Username
-
Password or SSH key
-
Port number, usually 22
⸻
Step 1: Connect to Your Old Hosting Account Using SFTP
Open your SFTP app and enter your old hosting account details.
Example:
Host: old-server.example.com
Username: your_username
Password: your_password
Port: 22
Protocol: SFTP
After connecting, look for your WordPress website folder. Common folder names include:
public_html
www
htdocs
domains/example.com/public_html
Inside the WordPress folder, you should see files and folders such as:
wp-admin
wp-content
wp-includes
wp-config.php
index.php
.htaccess
These are your WordPress website files.
⸻
Step 2: Download Your WordPress Files
Download all WordPress files from the old server to your computer.
The most important folder is:
wp-content
This folder contains your themes, plugins, media uploads, and custom website content.
However, for a full migration, you should download the complete WordPress directory, including:
wp-admin
wp-content
wp-includes
wp-config.php
index.php
.htaccess
Depending on the size of your website, this may take some time.
⸻
Step 3: Export the WordPress Database
WordPress stores posts, pages, users, settings, plugin data, and theme options in the database. The files alone are not enough to fully move the website.
Log in to phpMyAdmin or your hosting database manager on the old hosting account.
Then:
-
Select the WordPress database
-
Click Export
-
Choose Quick export
-
Choose SQL format
-
Download the .sql file to your computer
If you are not sure which database your WordPress site uses, open the wp-config.php file and look for:
define('DB_NAME', 'database_name');
define('DB_USER', 'database_user');
define('DB_PASSWORD', 'database_password');
define('DB_HOST', 'localhost');
The DB_NAME value tells you which database belongs to the WordPress site.
⸻
Step 4: Create a New Database on the New Hosting Account
Log in to your new hosting account and create a new database.
You will need:
-
Database name
-
Database username
-
Database password
-
Database host
Save these details because you will need them in the next step.
⸻
Step 5: Upload WordPress Files to the New Server Using SFTP
Now connect to your new hosting account using SFTP.
Open the website root folder on the new server. This is usually:
public_html
www
htdocs
Upload all WordPress files from your computer to the new server.
Make sure these files are directly inside the website root folder:
wp-admin
wp-content
wp-includes
wp-config.php
index.php
.htaccess
Do not accidentally upload the files inside an extra folder unless your hosting setup requires it.
For example, this is correct:
public_html/wp-admin
public_html/wp-content
public_html/wp-config.php
This is usually wrong:
public_html/wordpress/wp-admin
public_html/wordpress/wp-content
⸻
Step 6: Import the Database on the New Server
Open phpMyAdmin or your new hosting database manager.
Then:
-
Select the new empty database
-
Click Import
-
Upload the .sql database file you exported earlier
-
Click Go or Import
After the import is complete, your WordPress database has been moved to the new hosting account.
⸻
Step 7: Update the wp-config.php File
Open the wp-config.php file on the new server.
Update the database details to match the new database:
define('DB_NAME', 'new_database_name');
define('DB_USER', 'new_database_user');
define('DB_PASSWORD', 'new_database_password');
define('DB_HOST', 'localhost');
In many cases, the database host is:
localhost
However, some hosting providers use a different database host. If your site shows a database connection error, check the correct database host in your hosting panel.
⸻
Step 8: Update the Website URL If Needed
If your domain name is staying the same, you may not need to change anything.
If you are moving the website to a new domain, you need to update the WordPress site URL in the database.
In phpMyAdmin, open the WordPress database and find the table:
wp_options
Look for these two rows:
siteurl
home
Update both values to the new website URL.
Example:
If your table prefix is different, the table may not be called wp_options. It could be something like:
abc_options
⸻
Step 9: Test the Website Before Changing DNS
Before pointing the domain to the new server, test the website if your hosting provider gives you a temporary URL or preview link.
Check important pages such as:
-
Homepage
-
Blog posts
-
Contact page
-
Login page
-
Forms
-
Images
-
Menus
-
Checkout page, if using WooCommerce
Also log in to WordPress admin and check that the dashboard works.
The WordPress admin URL is usually:
https://yourdomain.com/wp-admin
⸻
Step 10: Point the Domain to the New Hosting Server
After confirming that the website works, update your domain DNS.
You may need to update:
-
Nameservers, or
-
A record, or
-
CNAME record
If your new hosting provider gives you nameservers, update the domain nameservers.
Example:
ns1.examplehost.com
ns2.examplehost.com
If your hosting provider gives you an IP address, update the domain’s A record.
Example:
A record
Name: @
Value: 123.123.123.123
DNS changes can take some time to fully update.
⸻
Step 11: Install SSL on the New Hosting Account
After DNS points to the new server, install SSL for the domain.
Most hosting providers offer free SSL through Let’s Encrypt.
After SSL is active, make sure your website loads with:
You should also check that the website does not show mixed content warnings. Mixed content usually happens when some images, scripts, or styles still load using http:// instead of https://.
⸻
Step 12: Fix Permalinks
After migration, log in to WordPress admin and go to:
Settings > Permalinks
Click Save Changes without changing anything.
This refreshes WordPress rewrite rules and can fix 404 errors on pages and posts.
⸻
Step 13: Check File Permissions
Incorrect file permissions can cause errors after migration.
Common WordPress permissions are:
Folders: 755
Files: 644
wp-config.php: 600 or 640
Avoid setting everything to 777. That is insecure and can put your website at risk.
⸻
Step 14: Final Website Checks
After the migration is complete, test the website carefully.
Check:
-
Website loads correctly
-
WordPress admin works
-
Images display properly
-
Contact forms send emails
-
Plugins are active
-
Theme settings are correct
-
SSL is working
-
Permalinks are working
-
No broken links
-
No missing CSS or JavaScript
-
WooCommerce checkout works, if applicable
You should also run a backup after the migration is complete.
⸻
Common WordPress Migration Problems
Error Establishing a Database Connection
This usually means the database details in wp-config.php are incorrect.
Check:
-
Database name
-
Database username
-
Database password
-
Database host
404 Errors on Pages
Go to:
Settings > Permalinks
Then click Save Changes.
Images Are Missing
This usually means the wp-content/uploads folder was not fully uploaded.
Reconnect using SFTP and upload the missing files again.
Website Redirects to Old Domain
Update the siteurl and home values in the database. You may also need to search and replace the old domain inside the database.
White Screen or Critical Error
This can happen because of plugin, theme, or PHP version issues.
Try renaming the plugins folder using SFTP:
wp-content/plugins
Rename it to:
plugins-disabled
Then reload the website. If the site works, one of the plugins is causing the issue.
⸻
Is SFTP Migration Safe?
Yes, SFTP migration is safe because the file transfer is encrypted. It is much safer than regular FTP.
However, SFTP only moves the website files. For a complete WordPress migration, you must also move the database.
The best practice is to take a full backup before starting the migration.
⸻
Conclusion
Migrating WordPress using SFTP is a reliable method when you want full control over your website files. The process involves downloading the WordPress files, exporting the database, uploading the files to the new server, importing the database, updating wp-config.php, and pointing the domain to the new hosting account.
If done carefully, SFTP migration can move your WordPress website with minimal downtime and without relying on migration plugins.