CSS throwing 503 error with node.js on a2hosting CSS throwing 503 error with node.js on a2hosting express express

CSS throwing 503 error with node.js on a2hosting


If you are able to see html and not CSS, try tweaking second parameter where you specify the directory location.

app.use('/testapp/static', express.static('public'));

The path that you provide to the express.static function is relative to the directory from where you launch your node process (link).

I had provided a sample code which you could refer where I had put one folder inside the directory and one outside. - https://codesandbox.io/s/sweet-grass-0dxvh?file=/testapp/server.js


Change From

app.use('/testapp/static', express.static('public'));

to

app.use('/testapp/static', express.static(path.join(__dirname, 'public')));

For express serving static files see link1 & link2.


  1. Please, make sure that your testapp is a correct Application URL (not Application root)

    ExpressJS configuration panel

  2. Your starting file is called server.js, however your package.json refers to app.js. Don't you have some additional files which may work instead of the one you think? Please, check the Application startup file is correct.

  3. If the first options didn't help, check the .htaccess file configurations in your /home/<username>/public_html directory according to the instructions https://www.a2hosting.com/kb/installable-applications/manual-installations/installing-node-js-on-managed-hosting-accounts#Integrating-a-Node.js-application-with-the-web-server

Please let me know if some of the options were helpful or you need some additional information or research.