Error 500 when i try to run a node application using cpanel but thats work runing on terminal in cpanel

huangapple go评论75阅读模式
英文:

Error 500 when i try to run a node application using cpanel but thats work runing on terminal in cpanel

问题

I'll provide the translated code snippets:

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");
});

If you need further assistance with the error messages or any other part of your code, please let me know.

英文:

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)

答案1

得分: 0

以下是要翻译的内容:

问题在于这里的第一行。

您正在连接到localhost上的mongodb,而不是连接到远程数据库。

只有在正确设置了VPS上的mongodb实例的情况下才可能实现这一点,这有点棘手,请考虑使用Mongo Cloud的免费版本:

https://www.mongodb.com/

英文:

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/

答案2

得分: 0

请始终注意你的应用程序运行的端口,通常浏览器使用80或443端口,但这些端口可能已被占用,我使用的是50000端口,所以当我插入链接时出错了。

英文:

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.

huangapple
  • 本文由 发表于 2020年1月3日 21:17:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/59579272.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定