skip to Main Content

I’ll send some code snippets because I think it can help who will help me. When I start the application by node.js in Cpanel and get access by url domain it falls into error 500 but when I start the application through Cpanel Terminal and access by IP: port the application works.

mongoose.connect("mongodb://127.0.0.1:27017/transparenciaBarrinha", { useNewUrlParser: true });
app.get("/receitas",(req,res)=>{
    Receitas.find({},(err,receitas)=>{
        if(err){
            console.log(err);
        }else{
            res.render("receitas", { receitas: receitas })
        }
    })
});
app.listen(50000,()=>{
    console.log("Running on port: 50000");
});

I have more code but is the same thing, I checked the files and they are working.
I went to the error screen and found this, if it repeats a few times, there are over 100 error lines of this kind, it seems to me to be something with the program being without permission to save the log

App 3465893 output:     at Socket.<anonymous> (/home/barrinhaspgov/nodevenv/public_html/transparencia/12/lib/node_modules/mongodb/lib/core/connection/connect.js:276:7)
App 3465893 output:     at callback (/home/barrinhaspgov/nodevenv/public_html/transparencia/12/lib/node_modules/mongodb/lib/core/connection/connect.js:247:5)
App 3465893 output:     at /home/barrinhaspgov/nodevenv/public_html/transparencia/12/lib/node_modules/mongodb/lib/core/connection/connect.js:31:7
App 3465893 output:     at /home/barrinhaspgov/nodevenv/public_html/transparencia/12/lib/node_modules/mongodb/lib/core/connection/pool.js:1007:11
App 3465893 output:     at /home/barrinhaspgov/nodevenv/public_html/transparencia/12/lib/node_modules/mongodb/lib/core/connection/pool.js:577:14
App 3465893 output:     at Pool.<anonymous> (/home/barrinhaspgov/nodevenv/public_html/transparencia/12/lib/node_modules/mongodb/lib/core/topologies/server.js:433:11)
[ N 2020-01-03 12:37:35.8451 3408777/T9 age/Cor/CoreMain.cpp:1117 ]: Checking whether to disconnect long-running connections for process 3463281, application /home/barrinhaspgov/public_html/transparencia (production)
[ N 2020-01-03 11:08:48.2647 3085542/T1 age/Cor/CoreMain.cpp:1117 ]: Checking whether to disconnect long-running connections for process 3371764, application /home/barrinhaspgov/public_html/transparencia (production)
[ N 2020-01-03 11:08:48.2618 3085542/T1 age/Cor/CoreMain.cpp:1117 ]: Checking whether to disconnect long-running connections for process 3371764, application /home/barrinhaspgov/public_html/transparencia (production)
[ E 2020-01-03 10:05:27.1194 3085542/T2i Log/Implementation.cpp:481 ]: opening file: /home/barrinhaspgov/public_html/transparencia for logging output failed. Error: Is a directory
[ E 2020-01-03 10:05:27.1180 3085542/T2i Log/Implementation.cpp:481 ]: opening file: /home/barrinhaspgov/public_html/transparencia for logging output failed. Error: Is a directory
App 3371764 output: Wrong (uid/gid) for file: /home/barrinhaspgov/public_html/transparencia Permission denied. Аn attempt to use the file not owned by user for logging /home/barrinhaspgov/public_html/transparencia (production) output
[ E 2020-01-03 10:05:24.4914 3085542/T2i Log/Implementation.cpp:481 ]: opening file: /home/barrinhaspgov/public_html/transparencia for logging output failed. Error: Is a directory
[ N 2020-01-03 10:05:23.6239 3085542/Tb age/Cor/CoreMain.cpp:1117 ]: Checking whether to disconnect long-running connections for process 3357576, application /home/barrinhaspgov/public_html/transparencia (production)

2

Answers


  1. Chosen as BEST ANSWER

    Always pay attention to the port that you are running in your application, usually the browser uses 80 or 443 but these were busy and I was using 50000 and so when I plugged in the link was wrong.


  2. The problem in here is in the very first line.

    You are connecting to the mongodb on localhost instead of connecting to a remote db.

    This is possible only if you correctly setup yourself a mongodb instance on the vps, which is kind of tricky, please consider a free version of Mongo Cloud:

    https://www.mongodb.com/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search