18

I installed Magento successfully, but the Admin page gives error: 404 not found. Please suggest a solution for this.

The following is the error:

404 Not Found

nginx/1.10.0 (Ubuntu)
4
  • where did you get nginx config?
    – MagenX
    Commented Aug 30, 2016 at 6:07
  • try siteurl/index.php/admin Commented Sep 19, 2016 at 12:11
  • Having custom different ports for secure and unsecured base_url also can be the issue. Mine was: somehost.com:4226 somehost.com:6226 As result I get 404 when try to access Admin. Commented Mar 18, 2019 at 19:47
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review Commented Mar 19, 2019 at 4:20

16 Answers 16

29

For Linux edit the file /etc/apache2/apache2.conf

To edit this file use sudo vi /etc/apache2/apache2.conf command

<Directory /var/www/>
     Options Indexes FollowSymLinks
     AllowOverride None
     Require all granted
</Directory>

to

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

After this run command

sudo service apache2 restart

IF STILL ADMIN SHOW 404 NOT FOUND, FOLLOW THIS STEP

1) Add .htaccess at root of magento 2

https://github.com/magento/magento2/blob/2.3-develop/.htaccess

2) Now run this command

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy

rm -rf var/cache/*

rm -rf var/generation/*

2
  • what are you talking about???? nginx ≠ apache
    – MagenX
    Commented Dec 22, 2017 at 19:44
  • 1
    Agreed. The OP references Nginx. But as I did have the same problem with Apache 2.4, what I found worked was a) a2dismod rewrite (even though it was enabled!), then b) restart Apache, then c) a2enmod rewrite and then d) restart Apache again. This solved the problem and it was the second time I encountered this on a new install of Apache. And clear cache and pray of course :) Commented Feb 24, 2018 at 11:35
28

Please try Below steps

  1. Delete var/cache folder
  2. Go to database SELECT * FROM core_config_data WHERE path = 'web/seo/use_rewrites' and make it 0
  3. Then enter url in your browser magento_base_url/index.php/your_admin_url

try and let me know if you face any issue.

6
  • What does this web/seo/use_rewrites value do?
    – Niels
    Commented Oct 4, 2018 at 9:04
  • 2
    @Niels it will remove index.php from url if it sets to 1 Commented Oct 4, 2018 at 10:32
  • @MurtuzaZabuawala Still i am getting same error where i need to focus?
    – zus
    Commented Nov 19, 2019 at 10:20
  • @zus please check backend=>frontname in app/etc/env.php file Commented Nov 19, 2019 at 13:33
  • @MurtuzaZabuawala I serve magento2.4 using php internal server with command php -S localhost:8080 -t pub, I tried your solution, but still get 404 when request localhost:8080/index.php/magento2/admin_1ibt8z Commented Jul 27, 2020 at 4:01
9

Why nobody talk about ?

bin/magento info:adminuri

This will display your adminuri. More info can be found here.

6

I also had this issue, it turned out one of my URLs was set to the IP address and not to the domain name so going to the {domain}/admin was returning not found.

Solution was to run

php bin/magento config:set web/secure/base_url https://domain.com/
php bin/magento config:set web/unsecure/base_url https://domain.com/

Don't forget the trailing slash, it will not work without it https://alanstorm.com/invalid-base-url-value-must-be-a-url-or-one-of/

2
  • this fix worked for me after migrating an old 2.0.15 installation to 2.2.x. During the setup the un-secure url did not have https:// protocol and was the default, the admin url, in the advanced section was configured to use https:// but they BOTH need to be set to be https otherwise page not found issue occurs. Commented Oct 20, 2018 at 14:57
  • Yes, thanks, I had too many stores to change and I forgot web/unsecure/base_url where the scope_id is 1 Commented Nov 3, 2020 at 14:41
6

Check if admin/url/custom is empty and admin/url/use_custom is set to 0.

4

Other possible solution is to check for .htaccess file in root directory and add if it doesn't exists (https://github.com/magento/magento2/blob/2.4-develop/.htaccess)

3

I have also same issue. I updated value for "admin/url/custom" to 0 in core_config_data table and my issue resolved.

2

Check if the mod_rewrite module is enabled in Apache. To enable mod_rewite module, go to httpd.conf file located at /etc/apache2/httpd.conf and look for "LoadModule rewrite_module libexec/apache2/mod_rewrite.so", if it is commented, then uncomment it by removing # at the front.

1
  • The OP was about Nginx - but as I mentioned above to @Prince Patel, the thing that worked for me was: 1. a2dismod rewrite 2. service apache2 restart 3. a2enmod rewrite 4. service apache2 restart - seems that disabling and enabling rewrite does the job. Commented Feb 24, 2018 at 11:37
2

I solved this issue after server migration by query db & get custom admin url

Actually my env admin path not working for admin login url

'backend' => [ 'frontName' => 'myadmin' ], http://www.magento.lan/myadmin 404 erorr

Check Admin Url:

bin/magento info:adminuri

Solution:

Step1: First Get Custom admin path

SELECT * FROM `core_config_data` where path like "%admin/url/custom_path%";

Step2: Disable Custom admin Path

Disable from db:

UPDATE `core_config_data` SET `value` = '0' WHERE `core_config_data`.`path` LIKE "%admin/url/use_custom_path%";

Disable from admin:

AdminLogin==>Store=>Configuration=>Advanced=>Admin=>Admin Base URL=>Use Custom Admin Path:=No

I hope it will be save time for someone

1

Hope this will help you

bin/magento setup:static-content:deploy Run this command In your CLI

1
  • Curious, how is this a solution for the admin returning a 404?
    – Tisch
    Commented Aug 6, 2018 at 8:11
1

Check this for Magento 2.4.3 and Apache 2

sudo subl /etc/apache2/apache2.conf

<Directory /var/www/>
 Options Indexes FollowSymLinks
 AllowOverride All
 Require all granted
</Directory>

sudo a2enmod rewrite

systemctl restart apache2

In core_config_data change the web/unsecure/base_url to url + pub/

example

http://mylocal.com.co/magento/magento24 to http://mylocal.com.co/magento/magento24/pub/

delete cache of magento

php ./bin/magento cache:flush

enter image description here

Frontend.

enter image description here

0

First you have to remove content from var/cache and var/session folder ,then change execute this command from commandline/terminal

bin/magento setup:static-content:deploy

1
  • 2
    Curious, how is this a solution for the admin returning a 404?
    – Tisch
    Commented Aug 6, 2018 at 8:11
0

Just try http://127.0.0.1/ instead of http://127.0.0.1 which worked for me

0

Below is the quick one that I had faced with v2.2.5 and fixed like below.

Go to

cd /your-project-root-folder/app/

and fire

chmod -R 755 etc/
0

I had a similar issue, as well. For me removing the all var folder by: rm -rf var/ and clearing all browser cache: Cmd+Shift+Delete or Command-Shift-Delete for mac, did the trick.

I hope it will help someone!

0

go check you /app/etc/env.php file backend[front_name => admin_kjdfk]. and use this, like base_url/admin_kjdfk

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.