Sometimes things work in a strange manner and WordPress is a best example for that. While it takes less than five minutes to install a live WordPress site, many of them will fail in creating a local copy of the live site. It is easy to create a live WordPress site in few minutes using one-click installer packages like Softaculous. Most of the popular hosting companies like Bluehost, SiteGround and HostGator offer one-click installation of WordPress CMS on their cPanel. However, the problem comes when you plan to create a copy of your live site to a local server. You need local copy for many reasons; for instance, you can do testing of a new plugin or try to change the theme. In most of the cases, you may simply need a safe backup of your live server in local computer. If you are struck, here are 5 reasons to troubleshoot why your WordPress local setup may fail to work.
Related: How to install localhost using MAMP in Mac?
11 Reasons Why Your WordPress Localhost Setup Fails
1. Caching Plugin
The localhost setup is a lengthy part needs three types of files – WordPress installation package, your site files and database file. When you backup the live site, you probably download all the plugins part of the live site. Most of the caching plugins will work only on the live server environment and throw error when you try to login to your localhost admin dashboard. However, some plugins will completely prevent you to access the site. Therefore, ensure to delete the caching plugin folder from your local “/wp-content/plugins” section.
If everything is working fine but you see the site content is scrambled then just delete the caching plugin and check.
2. Security Plugin
Most of us protect the live site with a security plugins like Wordfence or All in one WP security and firewall plugin. These security plugins create lot of stuffs in the backend.
- Database table entries
- Htaccess entries
- Additional drop-ins for outside plugins folder
Ensure to remove all the security related stuffs from your localhost and try whether it works.
3. .htaccess Entries
Some local server installations don’t need htaccess file while some servers need this file to work properly. There are two things to ensure if your installation needs htaccess file.
- Security and caching plugins will create lots of directives in htaccess file. Ensure to remove all these unnecessary entries as you may need to delete the security and caching plugins.
- WordPress needs htaccess entries to work properly for the permalink settings. Therefore, ensure the default permalink entries are available in your localhost’s htaccess file.
Remember, due to the reason the file starts with a dot, .htaccess file is generally hidden on your server and computer. You first need to enable the viewing of hidden files in your FTP client to download the file from the server. Similarly, you should enable viewing the hidden files on your computer to modify it.
4. Using HTTPS in Localhost
There are some tools like Local By Flywheel allows you to easily create a HTTPS localhost site. Alternatively, you can also use the premium version of MAMP to create secured virtual host server. However, localhost by default only works with HTTP protocol. If you have wrongly replaced the live URLs in your database with https://localhost then the entire localhost will not be available. When you try to localhost with https protocol, Chrome and other browsers will show you connection refused error like below.
5. Database Name
The other important part is the name of the database. Unless you change the name of the database everywhere, the easy way is to create a local database with the same name as your live site’s database. Otherwise, you will see an error when importing your database in phpMyAdmin. You will also see the popular connecting to your database error when the database name is not matching in “config.php” file.
In addition, ensure that you same MySQL and PHP version on both local and live server setup.
Related: How to setup local server in Windows using XAMPP?
6. Exporting All Tables in Database
Avoid downloading the entire database and importing on your local server. As mentioned above, security, caching and many other plugins may create tables, which may not work in local server setup. If you have problem in setting up local site database, then ignore those unnecessary tables in your database. You can go to your live server’s phpMyAdmin section and select the tables to import manually. This also will reduce the size of your database file.
7. Uploading Larger Database in phpMyAdmin
WordPress installation by default limits the file upload size using PHP settings. Even you increase the file upload size in the frontend, it is not possible to import a larger database file in the phpMyAdmin. If you have a larger database then try to upload through command prompt in Windows or Terminal in Mac.
8. Forget to Replace Live URLs
Probably everything worked fine for you, however when you access the localhost site it may redirect you to the live site. The most possible reason is that you forgot to replace the live site’s URLs with the localhost URL in your database.
- You need to replace the URLs in options, post and postmeta tables.
- You may need to replace the sidebar and footer links manually as it depends on your theme settings or you might have provided absolute URLs.
Related: How to setup WordPress localhost site using WAMP?
9. Hotlink Protection
Hotlink protection prevents others to steal your image and publish on their site with your original URL. You can enable hotlink protection from cPanel or using a security plugin. In this case, all media files on your localhost will not load and show blank space. Therefore, if you are not seeing the images on your localhost site check and disable your hotlink protection.
10. Using Incorrect Ports
Your localhost site’s URL will change based on your port setup. Generally, you have two types of ports:
- Apache / Nginx – 80 and MySQL – 3306. If you use these ports, you can access the site using “http://localhost/” URLs. However, every time you need to provide your admin password for accessing the local server.
- Apache / Nginx – 8888 and MySQL – 8889. If you use these ports then you should access the site using “http://localhost:8888/” URLs.
11. Premium Theme or Plugin Needs Activation Code
Most of the premium themes and plugins need an activation code to enable on the site. These premium stuffs will only work on single activated site when you have a single domain license. It may work on local site when you download / upload the live site’s files. However, it will reset the license domain when you update from local server. For example, popular Jetpack plugin will ask you activate the local server to keep the license active on live and local sites. Also, most of the membership and image compression plugins that need to contact server will not work from local computer. Therefore, try to disable the premium plugins and themes and use a free theme for your localhost setup if you face problems.
If you are still struck after checking all the above points then you two have options. One is to delete all your local files completely and reinstall afresh. Other is to try a different tool that can help you to easily setup.
Leave a Reply
Your email is safe with us.