{"id":508,"date":"2019-07-16T10:30:50","date_gmt":"2019-07-16T10:30:50","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2019\/07\/16\/fixed-failed-to-load-resources-error-after-magento-2-installation\/"},"modified":"2025-05-22T16:18:24","modified_gmt":"2025-05-22T10:48:24","slug":"fixed-failed-to-load-resources-error-after-magento-2-installation","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/fixed-failed-to-load-resources-error-after-magento-2-installation\/","title":{"rendered":"[Fixed] \u2013 \u201cFailed to Load Resources\u201d Error After Magento 2 Installation"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Ever faced an issue of \u201cFailed to load resource: the server responded with a status of 404 (Not found)\u201d for CSS and Js after installing Magento 2 on Wamp server windows?<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2019\/07\/Meetanshi-Programmer.gif\" alt=\"Meetanshi-Programmer\" class=\"wp-image-6047\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Try one of the below methods to get the solution:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solutions for \u201cFailed to Load Resources\u201d Error After Magento 2 Installation:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution 1:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Give proper permissions, enable apache rewrite_module and refresh apache server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod -R 777 MAGENTO_2_ROOT_DIRECTORY\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Run the following command from Magento root for fixing the frontend:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bin\/magento setup:static-content:deploy<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Clear&nbsp;<code>var<\/code>&nbsp;directory except&nbsp;<code>.htaccess<\/code>&nbsp;file and check admin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you get 404 page, there may be an issue of&nbsp;<code>Symlink<\/code>. Edit&nbsp;<code>apache config<\/code>&nbsp;file<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong>&nbsp;Implement this only if you are using&nbsp;<strong>apache<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo gedit \/etc\/apache2\/apache2.conf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace the below code:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;Directory \/var\/www\/>\nOptions Indexes FollowSymLinks\nAllowOverride none\nRequire all granted<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">with:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;Directory \/var\/www\/>\nOptions Indexes FollowSymLinks\nAllowOverride All\nRequire all granted<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong>&nbsp;Change AllowOverride None to AllowOverride All<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Restart apache&nbsp;<code>sudo service apache2 restart<\/code>&nbsp;and check admin. It fixes the admin 404 issue.<br>Moreover,&nbsp;make sure, you don\u2019t leave \/app\/etc\/ directory writeable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution 2:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Css and js is created at run time in&nbsp;<strong>pub\/static<\/strong>&nbsp;folder.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At first, if css and js is missing,&nbsp;run the below command:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For Windows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>binmagento setup:static-content:deploy<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For Linux of \u2018git bash\u2019:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bin\/magento setup:static-content:deploy<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution 3:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Update the&nbsp;<code>.htaccess<\/code>&nbsp;file under&nbsp;<code>\/pub\/static<\/code>&nbsp;folder.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open&nbsp;<code>MAGENTO_DIR\/pub\/static\/.htaccess<\/code>&nbsp;and add the below code:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteBase \/pub\/static\/ # &lt;- Add This<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Instead, you can also disable static file signing by adding this record into the core_config_data table with this query:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">INSERT INTO `core_config_data` VALUES (NULL, 'default', 0, 'dev\/static\/sign', 0);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution 4:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using Magento 2.3.X version, this solution is for you:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Change the above&nbsp;<code>foreach<\/code>&nbsp;loop to run our Magento with no further issues on this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#\/vendor\/magento\/framework\/View\/Element\/Template\/File\/Validator.php:139\nforeach ($directories as $directory) \n{\n    \/\/ Add this line\n    $realDirectory = $this->fileDriver->getRealPath($directory);\n    \/\/ and replace `$directory` with `$realDirectory`\n    if (0 === strpos($realPath, $realDirectory)) \n    {\n        return true;\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Hopefully, you are able to fix the error with one of the above solutions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Also read:<\/strong>&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/alternative-to-magento-2-deprecated-load-save-and-delete-methods\/\" target=\"_blank\" rel=\"noreferrer noopener\">Alternative to Magento 2 Deprecated Load, Save and Delete Methods<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever faced an issue of \u201cFailed to load resource: the server responded with a status of 404 (Not found)\u201d for CSS and Js after installing&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-508","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/508","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=508"}],"version-history":[{"count":2,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/508\/revisions"}],"predecessor-version":[{"id":15342,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/508\/revisions\/15342"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=508"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}