Magento from live - local server display 404 error message

Magento from live - local server display 404 error message

August 26, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento from live - local server display 404 error message

Solving the Magento 404 Error After Migrating to Localhost

Moving an e-commerce site like Magento from a live server to your local machine can sometimes lead to unexpected issues, such as the infamous 404 Not Found error when clicking navigation menus. In this post, we’ll diagnose and resolve the Magento 404 error you’re facing after migrating your site.

Understanding the 404 Error in Context

The 404 error occurs because the server cannot find the requested resource at the specified URL. In your case, the home page loads perfectly, but clicking any menu item leads to a 404 error because the server doesn’t know how to handle those specific URLs.

The Root Cause: Base URL Configuration

The problem likely stems from the base URL configuration in your Magento setup. When you moved the site, the base URLs stored within the database remained pointed at the live server’s domain or IP address.

Step-by-Step Solution

To resolve this issue, we need to update these base URLs and configure your local environment properly.

1. Update the Base URLs in the Database

First, let’s update the base URLs stored in the Magento database tables.

UPDATE core_config_data SET value='http://localhost/bc/' WHERE path='web/unsecure/base_url';
UPDATE core_config_data SET value='https://localhost/bc/' WHERE path='web/secure/base_url';

Replace http://localhost/bc/ and https://localhost/bc/ with the correct URL for your local environment.

2. Update the URLs in the .htaccess File

Next, open your Apache configuration file (.htaccess located in the Magento root folder) and update the following lines:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^bc\.com [NC]
RewriteRule ^(.*)$ http://localhost/bc/ [L,R=301]

# 301 Redirect for secure connection
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,NE]

Replace bc.com with the appropriate domain name or IP address from your live server.

3. Update Your Localhost Hosts File

Finally, you need to update your local machine’s hosts file (C:\Windows\System32\Drivers\etc\hosts) to map the Magento site’s domain to the localhost:

127.0.0.1       bc.com

Save and close this file.

Conclusion

The 404 error in your Magento setup is a common issue that arises when migrating sites between servers or environments. By updating the base URLs within the database, modifying the .htaccess configuration, and adjusting your local machine’s hosts file, you can ensure that your Magento site works properly on your localhost.

Remember to always update these changes after testing thoroughly before deploying them to a live server again. If you need further assistance with migrating or optimizing your Magento site, consider reaching out to professional services like those offered by Laravel Company.

Database Configuration Errors CLI

Our network