Search code examples
node.jsexpresshttp-status-code-403

NodeJS Express Website Error 403 on public server


I have a super simple NodeJS Express site setup with the following Folder Structure:

enter image description here

Views just contains a singe file index.ejs and public just a few .css and .js files required to make my site work (bootstrap, jquery etc.).

Using this on my local machine works great, however, the moment I put it on my live server (Shared Hosting on A2 Hosting), trying to open the page gives me Error 403, any ideas of what I'm missing?

Here is my servers.js file:

var express = require('express'),
path = require('path'),
nodeMailer = require('nodemailer'),
bodyParser = require('body-parser');

var app = express();
app.set('view engine', 'ejs');
app.use(express.static('public'));
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());   
app.get('/', function (req, res) {
  res.render('index');
});

Solution

  • Have you tried all steps in their tutorial? https://www.a2hosting.com/kb/installable-applications/manual-installations/installing-node-js-on-managed-hosting-accounts

    Found it on StackOverflow: https://stackoverflow.com/a/32535632

    PS: I would prefer to write this as a comment, but I don't have enough reputation yet.