0

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 me@example.com
    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?

1 Answers1

1

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
Romeo Ninov
  • 5,263
  • 4
  • 20
  • 26