Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Server Error 500 #3

Open
stalker-66 opened this issue Jan 22, 2024 · 41 comments
Open

Internal Server Error 500 #3

stalker-66 opened this issue Jan 22, 2024 · 41 comments

Comments

@stalker-66
Copy link

Hello!
I did everything according to the instructions.

Installed - https://github.com/virtuosoft-dev/hestiacp-pluginable
Installed - https://github.com/virtuosoft-dev/hcpp-nodeapp

User have bash ssh.
I created a web and I had a nodeapp folder (home/web/domain/nodeapp).

When I go to my link I see a 500 error.

app.outapps.info.error.log:

2024/01/22 19:30:45 [error] 2098#2098: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 95.135.30.188, server: app.outapps.info, request: "GET /favicon.ico HTTP/2.0", upstream: "http://127.0.0.1:50000/favicon.ico", host: "app.outapps.info", referrer: "https://app.outapps.info/"
2024/01/22 19:32:37 [error] 1559#1559: *2 connect() failed (111: Connection refused) while connecting to upstream, client: 95.135.30.188, server: app.outapps.info, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:50000/", host: "app.outapps.info"
2024/01/22 19:32:37 [error] 1559#1559: *2 connect() failed (111: Connection refused) while connecting to upstream, client: 95.135.30.188, server: app.outapps.info, request: "GET /favicon.ico HTTP/2.0", upstream: "http://127.0.0.1:50000/favicon.ico", host: "app.outapps.info", referrer: "https://app.outapps.info/"
2024/01/22 19:36:33 [error] 1559#1559: *13 connect() failed (111: Connection refused) while connecting to upstream, client: 95.135.30.188, server: app.outapps.info, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:50000/", host: "app.outapps.info"
2024/01/22 19:36:33 [error] 1559#1559: *13 connect() failed (111: Connection refused) while connecting to upstream, client: 95.135.30.188, server: app.outapps.info, request: "GET /favicon.ico HTTP/2.0", upstream: "http://127.0.0.1:50000/favicon.ico", host: "app.outapps.info", referrer: "https://app.outapps.info/"

Help! What could be the problem?

How can I see the application's performance? If I log in via ssh, pm2 logs does not work in the console((((

@stalker-66
Copy link
Author

How to use log app and pm2?

@Steveorevo
Copy link
Collaborator

Did you set the backend template type to NodeApp?

@stalker-66
Copy link
Author

Did you set the backend template type to NodeApp?

Yes

@Steveorevo
Copy link
Collaborator

Is there an error log in the web domain's ./log folder, adjacent to public_html?

Let's check if NodeJS can be run by the command line. Login to the web domain's user account via SSH; can you get a NodeJS version number via:

node --version

@stalker-66
Copy link
Author

stalker-66 commented Jan 28, 2024

Is there an error log in the web domain's ./log folder, adjacent to public_html?

Let's check if NodeJS can be run by the command line. Login to the web domain's user account via SSH; can you get a NodeJS version number via:

node --version

node --version
v12.22.9

node.js installed and working

@Steveorevo
Copy link
Collaborator

Steveorevo commented Jan 28, 2024

That node version sounds very old. What OS is this? When you create a new site, and set the backend to NodeApp, a basic "Hello World" should have been created for you (along with the nodeapp folder). Do you see those files there?

@Steveorevo
Copy link
Collaborator

Also, what is the location that it reports for the Node runtime? Type:

which node

@stalker-66
Copy link
Author

That node version sounds very old. What OS is this? When you create a new site, and set the backend to NodeApp, a basic "Hello World" should have been created for you (along with the nodeapp folder). Do you see those files there?

A test project is created.

@Steveorevo
Copy link
Collaborator

Steveorevo commented Jan 29, 2024

This project installs multiple versions of NodeJS (current and the last two LTS (long term support) versions). The command:

which node

Should report that NodeJS is coming from the /opt/nvm/ folder; with a sub folder matching NodeJS v18, v20, etc.

What path are you seeing via "which node"?

@stalker-66
Copy link
Author

This project installs multiple versions of NodeJS (current and the last two LTS (long term support) versions). The command:

which node

Should report that NodeJS is coming from the /opt/nvm/ folder; with a sub folder matching NodeJS v18, v20, etc.

What path are you seeing via "which node"?

Ubuntu 22.04 64 bit

@Steveorevo
Copy link
Collaborator

It sounds like you're having trouble with the command:

which path

Are you able to login to the user account associated with the website domain via SSH and type:

which path ?

The default response should be something like:

/opt/nvm/versions/node/v20.10.0/bin/node

@LEO318x
Copy link

LEO318x commented May 10, 2024

Any solution to this error? I am having the same problem.

In my case:
OS: Ubuntu 22.04.4 LTS
Node version: v20.13.0

Path:
/opt/nvm/versions/node/v20.13.0/bin/node

@Steveorevo
Copy link
Collaborator

Which version of HestiaCP do you have installed? Note: this will only work with HestiaCP Ngnix+Apache2 setups. Do you have Nginx present?

@LEO318x
Copy link

LEO318x commented May 11, 2024

Which version of HestiaCP do you have installed? Note: this will only work with HestiaCP Ngnix+Apache2 setups. Do you have Nginx present?

Yes, I have nginx and apache2 installed.
HestiaCP: v1.8.11

@Steveorevo
Copy link
Collaborator

Steveorevo commented May 11, 2024 via email

@LEO318x
Copy link

LEO318x commented May 11, 2024

For the given user, SSH should be enabled for the account. hcpp-nodeapp uses PM2 (process manager 2) to manage NodeJS apps. Login as that user on terminal window and type: pm2 ls Do you see any resulting process list? Or an error message?

On Saturday, May 11, 2024, Mike Molina @.> wrote: Which version of HestiaCP do you have installed? Note: this will only work with HestiaCP Ngnix+Apache2 setups. Do you have Nginx present? Yes, I have nginx and apache2 installed. HestiaCP: v1.8.11 — Reply to this email directly, view it on GitHub <#3 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE3EB4HY3ZFLKF4QZVOT5TZBZHBVAVCNFSM6AAAAABCFYLJEWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBVHE2TSMRXHE . You are receiving this because you commented.Message ID: @.>

It shows me a table with empty content.
2024-05-11_11-46-15

@Steveorevo
Copy link
Collaborator

Steveorevo commented May 11, 2024 via email

@LEO318x
Copy link

LEO318x commented May 11, 2024

Well that is a good sign; at least we can see some critical dependencies were installed. Let’s see if a port was properly allocated to your web app. Do you see a .ports file in a subfolder at: /usr/local/hestia/data/hcpp/ports/[username]/[domain].ports Where [username] and [domain] match your user and webapp domain? On Sat, May 11, 2024 at 10:47 AM Mike Molina @.> wrote:

For the given user, SSH should be enabled for the account. hcpp-nodeapp uses PM2 (process manager 2) to manage NodeJS apps. Login as that user on terminal window and type: pm2 ls Do you see any resulting process list? Or an error message? … <#m_4581956381624986963_> On Saturday, May 11, 2024, Mike Molina @.
> wrote: Which version of HestiaCP do you have installed? Note: this will only work with HestiaCP Ngnix+Apache2 setups. Do you have Nginx present? Yes, I have nginx and apache2 installed. HestiaCP: v1.8.11 — Reply to this email directly, view it on GitHub <#3 (comment) <#3 (comment)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE3EB4HY3ZFLKF4QZVOT5TZBZHBVAVCNFSM6AAAAABCFYLJEWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBVHE2TSMRXHE https://github.com/notifications/unsubscribe-auth/AAE3EB4HY3ZFLKF4QZVOT5TZBZHBVAVCNFSM6AAAAABCFYLJEWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBVHE2TSMRXHE . You are receiving this because you commented.Message ID: @.
> It shows me a table with empty content. 2024-05-11_11-46-15.png (view on web) https://github.com/virtuosoft-dev/hcpp-nodeapp/assets/7104835/a192fdf3-95a1-465a-9c43-a85a43a39bed — Reply to this email directly, view it on GitHub <#3 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE3EB5EKMLA2SAWNFUV7SLZBZKTTAVCNFSM6AAAAABCFYLJEWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBVHE3DOMJYGE . You are receiving this because you commented.Message ID: @.
**>

Yes, the file exists.

The content of the file is:
set $app_port 50000;

@LEO318x
Copy link

LEO318x commented May 12, 2024

Problem solved.
I rebuilt the vps, installed hestiacp again along with the plugin for node, and the problem was solved.

@yescit
Copy link

yescit commented Jun 29, 2024

hello I have the same exact issue, but I really don't want to reinstall my entire server to fix this :P

After following all the steps provided, when I visit the subdomain I get : 500 Internal Server Error
in the error log file I get the following

Connect() failed (111: Connection refused) while connecting to upstream, client:request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:50000/")

So, answering all the previous questions:

Hestia Control Panel v1.8.11
Operating System Ubuntu 22.04 (x86_64)

root@dev:~# which node
/usr/bin/node

root@dev:/opt/nvm/versions/node# ls
v16.20.2 v18.20.3

pm2 ls
image

This process is displyed because trying to make it work I replaced the Hello world script inside ../nodeapp with my actual node application (which is mirotalk https://github.com/miroslavpejic85/mirotalk )

/usr/local/hestia/data/hcpp/ports/[username]/[domain].ports

The content of the file is:
set $app_port 50000;

reading online on non hestiacp specific posts, this issue seems related to an nginx misconfiguration
I checked and nginx is up and running, even if I don't remember having ever configured it.

PS
I emailed you my server login, maybe it is of help debugging this issue!

At last, I don't know if it may be of help, here is the guide to configure apache2 / nginx for mirotalk (the nodejs app I am trying to install) https://docs.mirotalk.com/mirotalk-p2p/self-hosting/

@Steveorevo
Copy link
Collaborator

Nginx has a command line test switch. Login, and run.

sudo nginx -t

What is the output? It may give us a hint as to the mis-configuration.

@yescit
Copy link

yescit commented Jun 30, 2024

root@dev:~# nginx -t
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" di rective instead in /etc/nginx/conf.d/172.235.136.238.conf:17
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" di rective instead in /etc/nginx/conf.d/domains/dev.xxx.xx.ssl.conf:8
nginx: [warn] protocol options redefined for 172.235.136.238:443 in /etc/nginx/c onf.d/domains/miro.xxx.xx.ssl.conf:6
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" di rective instead in /etc/nginx/conf.d/domains/test.xxx.xx.ssl.conf:8
nginx: [warn] protocol options redefined for 172.235.136.238:443 in /etc/nginx/c onf.d/domains/test.xxx.xx.ssl.conf:8
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

@yescit
Copy link

yescit commented Jul 3, 2024

hello, any news? Did you receive my server credentials? Please when you have any minute give it a look, I am not the only one experiencing this issue (plus, I tried on another server.. Same issue again :P )

@Steveorevo
Copy link
Collaborator

Sorry, have not received any credentials. Check the email address you used? Your nginx -t does not appear to list anything obvious.

@yescit
Copy link

yescit commented Jul 11, 2024

hello, I re sent the email just now to steve AT steveorevo DOT com (I am writing like this in order for the bots not to spam you)

@Steveorevo
Copy link
Collaborator

This problem can occur if the given account holder (admin) does not have SSH access. A bash shell must be available to control the NodeJS processes. Please note "admin" is not recommended for setting up websites. Hestia should have warned you to create another user account just for websites. It's best to:

  1. use another account i.e. "marco" to create a website domain (not "admin" user).
  2. set "marco" user to allow SSH with bash.

See the screenshot at:
https://github.com/virtuosoft-dev/hcpp-nodeapp/blob/main/README.md#using-nodeapp-to-host-a-nodejs-website

@yescit
Copy link

yescit commented Jul 11, 2024

hello, thanks for your input: I double checked, in my case I am using another account ( name of the account "miro" ) and I selected 'bash' under SSH access. Still the same issue unfortunaltely.
Feel free to test anything you want on my server, if it could be of help to others experiencing the same issue :-)

@yescit
Copy link

yescit commented Jul 12, 2024

image
there is just one (a subdomain pointing to the server dedicated only to this user)

@Steveorevo
Copy link
Collaborator

I see. I noticed that miro/[domain]/nodeapp/node_modules has user/group root. This is a potential problem as all files under miro/[domain]/nodeapp should be owned by the Hestia user miro. Can you remove the nodeapp folder (as root user)? Then reselect NodeApp as the Proxy Template. This should copy over the basic "Hello World" nodeapp. We'll want to troubleshoot Hello World before trying your microtalk application.

Let me know when the default HelloWorld app is in the ./nodeapp folder and I can further diagnose the issue.

@yescit
Copy link

yescit commented Jul 12, 2024

ok so I cleared the miro/[domain]/nodeapp/* directory, then logged on hestia panel into miro user, ther re applied the proxy template "NodeApp"
image
clicked apply, waited some time, got the green "Changes Applied"
image
But unfortunately the "nodeapp" directory remains empty and if I visit the subdomain I now get this
image

@Steveorevo
Copy link
Collaborator

Clearing the directory will not cause the default hello world app to be installed; because it sees that you already have a nodeapp installed.

Set the proxy template to “default” first, then remove the nodeapp folder.

With the nodeapp folder removed, reset the Proxy Template to “NodeApp”, upon save, the HCPP-NodeApp plugin will create a proper nodeapp folder and default HelloWorld app for you.

@yescit
Copy link

yescit commented Jul 12, 2024

ok I performed all the actions above, now I have the Hello world app installed, but when I visit the subdomain I get the same error

image

@Steveorevo
Copy link
Collaborator

Ok, I can take a look at it from here. I will login with the credentials you furnished and will see if I can find anything wrong.

@Steveorevo
Copy link
Collaborator

We can manually start the HelloWorld app via login ssh (example: ssh [email protected]); and manually start the HelloWorld app via:

cd /home/miro/web/[domain]/nodeapp
pm2 start app.config.js

But on your server we get an error:

[PM2][ERROR] File app.config.js malformated
Error: Command failed: /bin/bash -c "source /opt/nvm/nvm.sh && nvm which v20"
    at checkExecSyncError (child_process.js:635:11)
    at execSync (child_process.js:671:15)

Upon further investigation we can see that Node version 20 is not installed:

nvm which v20
N/A: version "v20" is not yet installed.

You need to run `nvm install v20` to install and use it.

HCPP-NodeApp is designed to allow you to use multiple versions of NodeJS. It looks like you only have version v16 and version v18 installed. We can try to use v18 by simply changing the .nvmrc file. But the problem persists:

[PM2][ERROR] File app.config.js malformated
Error: Command failed: /bin/bash -c "source /opt/nvm/nvm.sh && nvm which v18"
    at checkExecSyncError (child_process.js:635:11)
    at execSync (child_process.js:671:15)

This tells me that maybe the HCPP-NodeJS plugin and automatic installation of NodeJS versions 16, 18, and 20 did not install completely. You may want to try to install it again. This would require root access. Restart your server to ensure any open files are closed and run the following as root:

/usr/local/hestia/plugins/nodeapp/uninstall
rm -rf /usr/local/hestia/plugins/nodeapp
rm /usr/local/hestia/data/hcpp/installed/nodeapp

Then re-install the HCPP-NodeApp plugin following the manual install directions or provide me with sudo access and I can attempt to install this for you.

@yescit
Copy link

yescit commented Jul 14, 2024

hello, so I performed all the steps above, installed nodejs 20 , reinstalled HCPP-NodeJS , reconfigured user miro. Unfortunately, I am experiencing the same exact issue "Internal server error 500". Feel free to make all the testing you want on my server, including removing older versions of nodejs and/or installing/uninstalling other packages, because I am really unable to find the bug

@Steveorevo
Copy link
Collaborator

Fixed. It looks like nvm and node v20 had conflicts with an existing nvm installation. HCPP-NodeApp is designed to install its own, new, NVM and Node versions in /opt/nvm. HCPP-NodeApp is usually installed on an untouched system (except for very old Node v12 that Ubuntu/Debian may have present). So an existing NVM is not common.

The non-standard /opt/nvm directory I have implemented is supposed to reduce conflict with any pre-existing version (say in /root/.nvm) but it looks like this actually complicates things further. I've removed the existing /root/.nvm and let the installer proceed with its own version at /opt/nvm.

However, given your issue; this maybe a problem with many users that try to do NodeJS stuff with Hestia. I'll look at the install script to be more compatible and forgiving with pre-existing NVM installations, and work with /root/.nvm in the future.

The HelloWorld is now functional and you can see how it works. When logging into miro shell, you can manage the process with PM2. I.e.

pm2 ls

Will list the HelloWorld process as running:

┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name               │ mode     │ ↺    │ status    │ cpu      │ memory   │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 0  │ app-miro.yesc.it   │ fork     │ 0    │ online    │ 0%       │ 53.1mb   │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘

@yescit
Copy link

yescit commented Jul 15, 2024

image
yesss it works now! Thank you very much indeed! So, If I would need to fix another server that I have, which is experiencing the same issue, without reinstalling everything should I: Remove any instance of nodejs and nvm , and then install v20 ?

@Steveorevo
Copy link
Collaborator

Do not install v20. The HCPP-NodeApp install process should do all that for you.

@yescit
Copy link

yescit commented Jul 15, 2024

ok, one last question, which maybe a bit out of scope here, but since I am getting the same internal server error 500, maybe related:
the app I want to run is called mirotalk https://github.com/miroslavpejic85/mirotalk

When I go to the installation process I read the following:

Before running MiroTalk P2P, ensure you have Node.js installed. This project has been tested with Node versions [12.X] [14.X][16.X]and [18.x]

-# clone this repo
$ git clone https://github.com/miroslavpejic85/mirotalk.git
-# go to mirotalk dir
$ cd mirotalk
-# copy .env.template to .env (edit it according to your needs)
$ cp .env.template .env
-# install dependencies
$ npm install
-# start the server
$ npm start

So I just put the entire content of the app inside ./nodeapp and rebooted

but still I get Internal Server Error when visiting the subdomain

finally, even manually starting the app

root@dev:/home/miro/web/miro.xxx.it/nodeapp# npm start

[email protected] start
node app/src/server.js

From the command line everything seems running fine except that Internal server error as soon as I visit the subdomain...

other info if useful https://docs.mirotalk.com/docs/self-hosting/

@Steveorevo
Copy link
Collaborator

Steveorevo commented Jul 16, 2024

Beyond the scope. But you can look at HelloWorld and a few other HCPP-based plugins that rely on HCPP-NodeApp for hints. First, you'll want to turn off the existing HelloWorld app. You can do this in 1 of 2 ways:

  1. Change the Proxy Template from 'NodeApp' to 'default' for the domain. Any running pm2 processes will automatically be quit.

OR

  1. Stop the existing HelloWorld app via ssh login as miro:
cd /home/miro/web/[domain]/nodeapp
pm2 stop 0

Above, zero is the ID of the HelloWorld app. That might be different; use pm2 ls to list all PM2 powered NodeJS processes.

Next, you will want to adjust the NodeApp to use NodeJS v18 instead of v20. HCPP-NodeApp makes this easy; just edit the .nvmrc file to say v18 instead of v20. You may also want to tell the ssh command line to use v18 if you are doing this from the terminal, i.e. nvm use v18.

Now to configure your app to use PM2. HCPP-NodeApp works by searching for all *.config.js files. When it finds one, it will use PM2 to start them. For example, the HelloWorld app has a file called app.config.js. This file, by default, will launch a the node program of the same name app.js. We can ignore the app.js, since it is NOT the program we want to launch. Instead, it looks like you want to launch app/src/server.js. You can customize that by telling PM2 to use the app/src/server.js script and you will also want to tell mirotalk to use a custom port. HCPP-NodeApp allocates a custom port for each NodeJS application, it can be found in the nodeapp._port variable. It looks like mirotalk's documentation says to set and environment variable called PORT.

In theory, the app.config.js file might look like this:

/**
 * Get compatible PM2 app config object with automatic support for .nvmrc, 
 * port allocation, and debug mode.
 */
module.exports = {
    apps: (function() {
        let nodeapp = require('/usr/local/hestia/plugins/nodeapp/nodeapp.js')(__filename);
        
        // Specify the mirotalk server script
        nodeapp.script = 'app/src/server.js';
        
        // Pass along an environment variable for the PORT mirotalk will look for
        nodeapp.env = {};
        nodeapp.env.PORT = nodeapp._port;
        
        // Pass this back to PM2
        return [nodeapp];
    })()
}

Once the file is edited, you should set the Proxy Template for the domain back to NodeApp; this will trigger HCPP-NodeApp to look for the app.config.js file and start the mirotalk application.

@yescit
Copy link

yescit commented Jul 20, 2024

Hello, now it works wonderfully, thank you! Also, I think the last post could be really useful if integrated in the first page of this project, as it explains better how this plugin works and could be successfully setup.
I also learned a couple of things about ownership of files and programs in linux: to make the story short ->beware to always log in to the user which operates pm2 and nodejs, in order not to create double or triple processes (for example by root user...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants