Score:0

Apache Cannot See PM2 Node Process

in flag

I have Apache running on Ubuntu 20 and I keep getting this error in /var/logs/apache2/error.log:

[proxy:error] [pid 7064] (111)Connection refused: AH00957: http: attempt to connect to 127.0.0.1:4000 (127.0.0.1) failed

[proxy_http:error] [pid 7064] [client ...] AH01114: HTTP: failed to make connection to backend: 127.0.0.1

My virtual host is set up like this:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on

# Reverse Proxy Stuff for Node
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:4000/ Keepalive=On
ProxyPassReverse / http://127.0.0.1:4000/ Keepalive=On

SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

In my web directory (/var/www/example.com) I started my app with pm2 like this:

pm2 start index.js -p 4000

When I do pm2 status I see that my process is online. There are no errors in pm2 logs. Somehow Apache and pm2 aren't talking to each other.

netstat -tulpn confirms that nothing is listening on port 4000.

I don't know what else to do. Any ideas?

Romeo Ninov avatar
in flag
According to PM2 guide you do not have key `-p`. Better add `--log` and check generated logs
Clifton Labrum avatar
in flag
Ah, you're right! My bad. Looks like doing `port=4000 pm2 start index.js` worked. Thanks!
Score:1
in flag

You can't define port with -p in PM2, there is no such option. Probably variable can do the work (as you mention in your comment):

port=4000 pm2 start index.js
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.