cancel
Showing results for 
Search instead for 
Did you mean: 

Css and JS not loading

SOLVED

Css and JS not loading

I am using Magento 2.4.4 with Nginx and Varnish

out of the blue all css/js stopped loading on my local server.

I checked the log and nothing is there.

I checked the permission and it should be all fine.

Clear all cache

 

The only error I get is on safari:

Failed to load resource: Could not connect to the server.    _________ .css

 

The question is why does .css/.js doesn't connect to the server???

 

Any help is welcome.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Css and JS not loading

Finally solved it... Here is how I did it:

 

1. Stopped Varnish and only work with Nginx

2. Reinstall initial config of Nginx

3. Restart my php-fpm process

 

Thanks Smiley Happy

View solution in original post

4 REPLIES 4

Re: Css and JS not loading

Hello @cmoi40 

 

Please set permission by using below commands:

find . -type f -exec chmod 644 {} \;               // 644 permission for files
find . -type d -exec chmod 755 {} \;               // 755 permission for directory 
find ./var -type d -exec chmod 777 {} \;           // 777 permission for var folder    
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;

chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml

and run below commands:

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush  
Problem solved? Click Accept as Solution!

Re: Css and JS not loading

Hi Bhanu,

 

   Thanks for the help. I followed the instructions and had no errors but somehow the css/js still doesn't show up and I get the same error on safari dev.

 

   I should also mention I am not using root but another user and using sudo.

 

   Any other suggestions?

 

Thanks

Re: Css and JS not loading

OK...getting closer to know what is going on. This seems to be a server issue since it redirects my css/js and images to a different port! plus each port is different. 

 

example: 

 

GET http://192.168.1.184/media/myshop/Demos/sp/a2logo.png net::ERR_CONNECTION_REFUSED
192.168.1.184/:443 GET http://192.168.1.184/media/myshop/Demos/sp/slide-headphones-bg.jpg net::ERR_CONNECTION_REFUSED
192.168.1.184/:468 GET http://192.168.1.184/media/myshop/Demos/sp/home-sp-slide-02.jpg net::ERR_CONNECTION_REFUSED
192.168.1.184/:14 GET http://192.168.1.184/static/version1662490507/frontend/Gurutoy/myshop/en_US/css/styles-l.css net::ERR_CONNECTION_REFUSED

 

As you can see various port are assigned to css/js/images... therefore this must be an issue with Nginx/Varnish.

 

 

Re: Css and JS not loading

Finally solved it... Here is how I did it:

 

1. Stopped Varnish and only work with Nginx

2. Reinstall initial config of Nginx

3. Restart my php-fpm process

 

Thanks Smiley Happy