Magento Tutorials

How to Fix Magento Admin 404 Error After Install

There’s a common error that Magento users face after installing their Magento site, even if the installation is successfull: 404 Not Found on admin page. This error also usually happens after installing or upgrading extensions.

How to solve Magento Admin 404 error

Since there are several possible causes for this, there are several possible solutions as well. You can do one by one until the problem is solved.

1. Recheck your admin URL in env.php

It could be that you mistyped your admin URL. To make sure that you have the admin URL correct, go to [..]/app/etc/ and open the env.php file.

admin is the url path to our Magento Admin

For example, with admin as our frontName, our admin url will be

2. Flush Magento cache

You can flush Magento cache using command line:

php bin/magento cache:clean
rm -rf var/cache/*
rm -rf var/generation/*

3. Serve files from the /pub directory

This solution is specifically for users on Magento version 2.4.2 and above. The reason that you may run into a 404 not found error after a fresh install of Magento 2.4.2 is due to a change starting from Magento 2.4.2, which requires you to set the webroot to /pub/ for better security.

To get around this, we recommend following the official guide by Magento. The whole process involves various steps such as: editing your server configuration, updating base URL, updating the env.php file, and switching mode.

4. Add/replace .htaccess file in the root folder

Add/replace the default .htaccess file in the root folder with the official .htaccess file from the Magento code base.

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/pub/
RewriteCond %{REQUEST_URI} !^/setup/
RewriteCond %{REQUEST_URI} !^/update/
RewriteCond %{REQUEST_URI} !^/dev/
RewriteRule .* /pub/$0 [L]
DirectoryIndex index.php

5. Delete var/cache folder

  • Delete var/cache folder
  • Go to your Magento 2 database and run the following SQL query:
SELECT * FROM core_config_data WHERE path = 'web/seo/use_rewrites'
  • And change the value of web/seo/url_rewrites to 0
web seo url rewrites in database
  • To see if this works, access your Magento Admin through: https://your_magent_base_url/index.php/your_admin_url/

Hope that helps!

Further Reading:

Magento Admin Login: How to Fix the “Not Working” Issue Compeletely
How to Fix Magento Connect Manager 404 Error
How to Fix 500 Internal Server Error in Magento

Is it helpful?

A knowledge craver who always strive to be wiser everyday.

Notify of
1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
1 year ago

c’est pas possible comme c’est de la merde ce magento