Passenger not starting node.js

Hi there! I’ve been following the Passenger/node.js dreamhost instructions for a while and I just can’t get the node.js app to run! I’ll see if I can provide a bunch of detail here. Thanks for any help you can provide!

My server structure:

[oin]$ tree

|-- Maildir
|   |-- cur
|   |-- new
|   `-- tmp
|-- logs
|   `-- vikingcap.app
|       |-- http -> /home/_domain_logs/dh_546vq2/vikingcap.app/http.42583625
|       `-- https -> /home/_domain_logs/dh_546vq2/vikingcap.app/https.42590600
`-- vikingcap.app
    |-- HelloWorld.js
    |-- app.js
    |-- favicon.gif
    |-- favicon.ico
    |-- public
    |   |-- favicon.gif
    |   `-- favicon.ico
    |-- refreshdatabase.sh
    `-- tmp
        `-- restart.txt

Contents of app.js:

import http from 'http';

http.createServer(function(request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello World. This page is running Node.js version: ");
  response.write(process.version);
  response.end();
}).listen(8888);

My dreamhost settings:

My .htaccess file (under vikingcap.app):

PassengerNodejs /home/dh_546vq2/.nvm/versions/node/v12.20.2/bin/node

Output of node -v:

v12.20.2

What my site looks like:

We’re sorry, but something went wrong.

We’ve been notified about this issue and we’ll take a look at it shortly.

Information for the administrator of this website

The Phusion Passenger application server encountered an error while starting your web application. Because you are running this web application in staging or production mode, the details of the error have been omitted from this web page for security reasons.

Please read the Passenger log file to find the details of the error.

Alternatively, you can turn on the “friendly error pages” feature (see below), which will make Phusion Passenger show many details about the error right in the browser.

To turn on friendly error pages:

Nginx integration mode
Apache integration mode
Standalone mode

Unfortunately, it appears that I don’t have permission to view the Passenger log / error files.

Let me know if I missed anything! Thanks.

Structure looks perfectly correct.

Double check that app.js is set as executable, reset the relevant user PAX flags and restart Passenger.

$ chmod 755 ~/vikingcap.app/app.js
$ setfattr -n user.pax.flags -v "mr" $NVM_DIR/nvm.sh
$ setfattr -n user.pax.flags -v "mr" $(find $NVM_DIR -type f -iname "node" -o -iname "npm" -o -iname "npx")
$ touch ~/vikingcap.app/tmp/restart.txt

Thanks for taking a look at this sXi! Here are the permissions now:

[oin]$ ls -al ~/vikingcap.app/app.js
-rwxr-xr-x 1 dh_546vq2 pg10169304 279 Feb 14 12:58 /home/dh_546vq2/vikingcap.app/app.js

Same problem though. curl 0.0.0.0:8888 returns Connection refused. Website shows the same passenger error.

That is normal behaviour – use the fully qualified domain if you have serverside code that uses the local app (e.g. $ curl vikingcap.app).

Some more guesses…

In app.js, alter the import directive to const http = require('http'); and touch your restart.txt again.

If still failing:

Ensure that .htaccess is chmod 644 (and check spelling).

Try nvm install a different version of node (you’ll need to reset PAX flags, update the node path in your .htaccess and touch restart.txt if you do).

Making the import a const didn’t change anything. curl https://www.vikingcap.app just hangs for a while before printing the phusionpassenger error message. Same as through browser.

chmod-ing the .htaccess didn’t change anything either.

I tried installing node v13.14.0 (the docs say that the dreamhost version of passenger doesn’t work with v14+). Here’s the whole process:

[oin]$ nvm install 13
Downloading and installing node v13.14.0...
Local cache found: ${NVM_DIR}/.cache/bin/node-v13.14.0-linux-x64/node-v13.14.0-linux-x64.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v13.14.0-linux-x64/node-v13.14.0-linux-x64.tar.xz


#
# Fatal error in , line 0
# Check failed: reservation_.SetPermissions(protect_start, protect_size, permission).
#
#
#
#FailureMessage Object: 0x3e03e95c480
 1: 0xa79671  [node]
 2: 0x19f5e75 V8_Fatal(char const*, ...) [node]
 3: 0xda3c3f  [node]
 4: 0xda69ad v8::internal::PagedSpace::SetReadAndExecutable() [node]
 5: 0xce6a36 v8::internal::Isolate::Init(v8::internal::ReadOnlyDeserializer*, v8::internal::StartupDeserializer*) [node]
 6: 0x10d4ed7 v8::internal::Snapshot::Initialize(v8::internal::Isolate*) [node]
 7: 0xba4efa v8::Isolate::Initialize(v8::Isolate*, v8::Isolate::CreateParams const&) [node]
 8: 0xa4df11 node::NodeMainInstance::NodeMainInstance(v8::Isolate::CreateParams*, uv_loop_s*, node::MultiIsolatePlatform*, std::vector<std::string, std::allocator<std::string> > const&, std::vector<std::string, std::allocator<std::string> > const&, std::vector<unsigned long, std::allocator<unsigned long> > const*) [node]
 9: 0x9de499 node::Start(int, char**) [node]
10: 0x36873899b97 __libc_start_main [/lib/x86_64-linux-gnu/libc.so.6]
11: 0x97cfa5  [node]
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v13.14.0` to unset it.

[oin]$ setfattr -n user.pax.flags -v "mr" $(find $NVM_DIR -type f -iname "node" -o -iname "npm" -o -iname "npx")

[oin]$ nvm use v13.14.0
Now using node v13.14.0 (npm v6.14.4)

[oin]$ node -v
v13.14.0

And updated my .htaccess to:

PassengerNodejs /home/dh_546vq2/.nvm/versions/node/v13.14.0/bin/node

And then for good measure did a chmod 644 .htaccess. Then ran touch tmp/restart.txt No luck. Still the same error page.

Honestly the only thing I can think of is maybe it has to do with https? I’m using a .app domain which means no http is allowed (HSTS). You’d think it would work just fine (after all, the error page is displaying just fine).

It seems more probable to be a serverside or user account issue. How did you create the files?

To test that hypothesis you could quickly add a (free!) vikingcap.dreamhosters.com subdomain owned by user dh_546vq2 then try a test app.js in it.

I originally copied (scp) my app.js from another computer (Windows), but since then I replaced all contents with the code seen above, using a ssh session and nano.

I’m not familiar with that process. Is there a page that explains that?

To set up a free dreamhosters subdomain:

Panel > Domains > Manage Domains

Click Add Hosting to a Domain / Sub-Domain button.

Domains to host: [whatever].dreamhosters.com
Run this domain under the user: [select user]
Set required Web Options and click Host This Domain

It should be up and running in a few minutes (and you can connect to http only).

Well that should remove any chance of file BOM or other such artifact weirdness, but I’d probably run a $ dos2unix command over all the relevant files in any case. If the command isn’t available on your server I think nano can switch line endings during the save procedure:
CTRL+O to start save procedure
ALT+D to switch between DOS/Unix
ENTER to save

Ran those commands and touched the restart file again. No luck.

Crazy. Try these files (tested and running over DH Passenger today).

$ cd ~/vikingcap.app
$ wget xnode.dreamhosters.com/test_node.zip
$ unzip test_node.zip

Hit A if asked to overwrite files.
Edit .htaccess to reflect your username in the path.

I just tried those with no success. Really weird. Does that server have HTTPS enabled via LetsEncrypt? And does it have Wordpress installed? (I never did the wordpress autoinstall because I knew I’d never be using it)

Honestly just grasping at straws at this point.

It’s running on a free dreamhosters.com subdomain (as described above) with Passenger and Node checked in hosting options.

https://xnode.dreamhosters.com

No need to install a certificate as Dreamhost have a wildcard certificate on the dreamhosters domain that covers any subbies we create.

If I were faced with this strangeness I’d try creating a [random].dreamhosters.com subdomain with Passenger+Node settings checked under a new user account (you can have unlimited users), then install nvm and dump those test files in the brand new setup as a test. If that fails then it’s likely a server issue, in which case you should ask DH to move you to a server that functions as expected.

I have the same problem
The error is on line 41 of /usr/share/passenger/helper-scripts/node-loader.js
‘GLOBAL’ has been depreciated and should now be ‘global’
I assume that the version of Passenger needs to be updated.
Is there a way that I can update the version of Passenger used?

App 9635 stderr: ReferenceError: GLOBAL is not defined
App 9635 stderr:     at Object.<anonymous> (/usr/share/passenger/helper-scripts/node-loader.js:41:1)
App 9635 stderr:     at Module._compile (node:internal/modules/cjs/loader:1091:14)
App 9635 stderr:     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1120:10)
App 9635 stderr:     at Module.load (node:internal/modules/cjs/loader:971:32)
App 9635 stderr:     at Function.Module._load (node:internal/modules/cjs/loader:812:14)
App 9635 stderr:     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
App 9635 stderr:     at node:internal/main/run_main_module:17:47

From the command line. the node app runs happily, the htaccess has the contents and permissions:
$ node app.js
This is a node app and is running on version v15.9.0
$ cat .htaccess
PassengerNodejs /home/nestedcube/.nvm/versions/node/v15.9.0/bin/node
$ ls -l .htaccess
-rw-r–r-- 1 nestedcube pg2302240 69 Feb 23 02:51 .htaccess

I have it working with v13.14.0, there is a GLOBAL depreciation warning in error.log, but it is serving my page and using the correct version

$ nvm install v13.14.0
$ setfattr -n user.pax.flags -v “mr” $(find $NVM_DIR -type f -iname “node” -o -iname “npm” -o -iname “npx”)
$ nano .htaccess
PassengerNodejs /home/nestedcube/.nvm/versions/node/v13.14.0/bin/node
$ touch tmp/restart.txt

You could install a custom version of Passenger if you’re on a dedicated server. The default installed version (~4 something?) provided by Dreamhost breaks down at nodejs v14.

I upgraded to VPS to try this, clearly not enough, is it possible to run node without Passenger?

You can, but to serve over ports 80 and 443 is a pain in the arse and comes with no official DH support.


EDIT: just came back because I realised ^ that response was vague and contained little value.

You could set up NGINX as a reverse proxy (but you void any official support).

1 Like

This post was flagged by the community and is temporarily hidden.