Showing results for 
Search instead for 
Did you mean: 

Magento 2.4.5 css and js error- frontend and admin.

Magento 2.4.5 css and js error- frontend and admin.


I have a strange problem after installing Magento 2.4.5 and 2.4.5-p3. The installation was successful in both cases, but I'm facing the same issue in both installations, which is that the CSS and JS files are not loading. Of course, I have set the permissions to 777 wherever necessary. I won't clutter the message with the entire console error code, so I'll provide the initial errors that are causing subsequent ones:

[HTTP/1.1 200 OK 156ms]

Content-Security-Policy Warnings 2









I'm not sure where the 'version1687376918' directory is coming from because it doesn't exist in that location on the server.

I would appreciate any help and suggestions. I've been working on this for a while and have tried various solutions, but haven't found anything that resolves this issue.

Additionally, here are the details of the environment: Debian 12, Apache 2.4, PHP 8.1, MySQL 8 installed on Docker.

I hope this helps. Let me know if you need any further assistance.


Re: Magento 2.4.5 css and js error- frontend and admin.

Hello @infonetter5554 


Ensure that the appropriate file permissions are set for the Magento installation directory. The recommended permissions for files are 644, and for directories, they are 755. You mentioned setting permissions to 777, but it's best to avoid excessive permissions for security reasons


Perform a fresh deployment of static content to ensure all required CSS and JS files are generated and available.

bin/magento setup:static-content:deploy


If you're working in a development environment, you can add the --no-optimization option to disable minification and bundling during static content deployment, making it easier to troubleshoot and locate any specific issues:


bin/magento setup:static-content:deploy --no-optimization

Make sure to specify the appropriate language/locale using the -l or --language option if needed.


Ensure that the correct user and group own the files and directories in your Magento installation. Verify that the Apache or web server user has proper ownership of the files and directories. You can use the chown command to adjust ownership if necessary


Double-check the base URL and base path configuration in your Magento installation. The base URLs should be set correctly in the Magento Admin under Stores > Configuration > General > Web. Make sure the URLs are accessible and properly configured for your environment


If you are using a strict Content-Security-Policy (CSP) configuration, it might be blocking the loading of CSS and JS files. Temporarily disable or modify the CSP configuration to allow the necessary resources to load. Once the issue is resolved, you can reconfigure the CSP according to your requirements.

Was my answer helpful? You can accept it as a solution.
175+ Professional Extensions for M1 & M2
Need a developer?Just visit Contact Us Now

Re: Magento 2.4.5 css and js error- frontend and admin.

Hello @infonetter5554 

Please try the following Steps : 

insert into core_config_data (config_id, scope, scope_id, path, value) values (null, 'default', 0, 'dev/static/sign', 0);

Run below commands : 

php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush
php bin/magento cache:clean