I have tried to install the NPM packages from the cpanel. But when I try to open the website, I get the response incomplete response received from application. When i run it offline, it works properly, but when i move it to the cpanel, it gives me the incomplete response error
var express = require("express"),
app = express(),
mongoose = require("mongoose"),
flash = require("connect-flash"),
passport = require("passport"),
LocalStrategy = require("passport-local"),
session = require("express-session"),
methodOverride = require("method-override"),
nodemailer = require("nodemailer"),
multer = require("multer"),
dotenv = require("dotenv").config(),
Product = require("./models/products"),
User = require("./models/user");
var mongoDB = process.env.MONGODB_URL;
mongoose.connect(mongoDB, { useNewUrlParser: true , useUnifiedTopology: true});
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'MongoDB connection error:'));
var indexRoutes = require("./routes/index"),
storeRoutes = require("./routes/products");
app.use(express.urlencoded({extended: true}));
app.use(express.json());
app.set("view engine", "ejs");
app.use(express.static(__dirname + "/public"));
app.use(methodOverride("_method"));
app.use(flash());
//User Passport Config
app.use(require("express-session")({
secret: process.env.SECRET,
resave: false,
saveUninitialized: false
}));
app.use(passport.initialize());
app.use(passport.session());
passport.use(new LocalStrategy(User.authenticate()));
passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());
app.use(function(req, res, next){
res.locals.currentUser = req.user;
res.locals.error = req.flash("error");
res.locals.success = req.flash("success");
next();
});
app.use(indexRoutes);
app.use("/store", storeRoutes);
app.use(function(req, res){
res.send ("Error finding page")
})
const port = process.env.PORT;
app.listen (port, function(){
console.log ("Server Active");
});
this is what i saw in the the .htaccess
file. I only placed some passwords and other private info in the .env
file
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php70” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php70 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION BEGIN
PassengerAppRoot "/home/zenitcou/zenitcouture"
PassengerBaseURI "/"
PassengerNodejs "/home/zenitcou/nodevenv/zenitcouture/11/bin/node"
PassengerAppType node
PassengerStartupFile app.js
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION END
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION BEGIN
<IfModule Litespeed>
</IfModule>
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION END
3
Answers
Share the response you are getting, that we can help you better
From the configuration provided, I can’t tell the exact cause but I may have enough experience why you end up getting "incomplete response received from the application".
The error message might be confusing, but what it really wants to say is, nothing is actually sent from your app upon HTTP request is sent by the proxy aka. Phusion Passenger.
You can read more about what are those Passenger config in their docs
but my gist is one of these:
PassengerAppEnv development
to track error messages.app.listen
port you’re giving on. But it probably crashes because you set themundefined
. Please set a fallback on yourPORT
env likeconst port = process.env.PORT || 80;
PassengerStartupFile
asapp.js
. Is it true? (People usually set their main entry file asserver.js
. You have to make sure the file exists.I faced the same error.
For me, it was log4js. The process.send() function was undefined.
By disabling the clustering of log4js, all become fine.
To find where the error is, I proceeded with code reduction. Compiling a few lines of codes
May it helps someone