Showing results for 
Search instead for 
Did you mean: 

Post Migration CSS/JS Files Fail To Load

Post Migration CSS/JS Files Fail To Load

Upon migrating to a new server not all of the CSS and JavaScript was loading. After some initial troubleshooting where I was seeing types errors in the console, and eliminating a missing REL attribute on the CSS or incorrect types listed for the CSS and JS files, I learned that the types errors could actually be, and then confirmed they were in this case, that the files were “missing”.


To mitigate this I took the following steps:

  1. Updating the base, public and static secure/unsecure URLs in the database/.

  2. Ensuring the URL’s ended in “/”

  3. Toggling off and on the CSS and JavaScript merge

  4. Deleting the contents of the pub/static/frontend/, pub/static/adminhtml/, var/view_preprocessed/, var/generated/ and var/cache/ folders.

  5. Ran the following commands:

    1. bin/magento setup:upgrade

    2. bin/magento setup:di:compile

    3. bin/magento setup:static-content:deploy -f

    4. bin/magento cache:clean

    5. bin/magento cache:flush

  6. Ensuring the pub/static/.htaccess file is present

  7. Ensuring the re-deployed folders and files had the correct ownership

  8. Ensuring the folders, especially those redeployed had the correct permissions using:

    1. find . -type d -exec chmod 755 '{}' \;

    2. find . -type f -exec chmod 644 '{}' \;

    3. find var -type d -exec chmod 777 {} \;

    4. find pub/static -type d -exec chmod 777 '{}' \;

    5. find pub/media -type d -exec chmod 777 '{}' \;

    6. chmod 777 app/etc

    7. chmod 644 app/etc/*.xml

  9. Refreshing my browser’s cache


I was following steps 3 through 7 plus 9 several times and it was showing the same behavior.


Digging a little deeper I was able to determine that, each time after following those steps, the browser was consistently pulling the deployment version that was one version behind the version listed as current in the deployed_version.txt file.


After realizing the redeployment was adding in different file ownership and permissions I added step 8.


Despite the deployed version the browser is trying to pull from now matching the current version listed in the deployed_version.txt file, and confirming that the files exists in the directories that they are pulling from, I’m still getting the type error which is causing the loading of the css and js files to fail.


Any insight into what combination of commands, files changes, or database changes might fix this behavior would be greatly appreciated.


Magento Version:

  • 2.3.5 CE

Server Configuration:

  • Ubuntu 18.04

  • Nginx 1.21.6

  • MariaDB 10.7.7

  • PHP 7.3.33