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 [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?

2
  • According to PM2 guide you do not have key -p. Better add --log and check generated logs Aug 29 at 6:14
  • 1
    Ah, you're right! My bad. Looks like doing port=4000 pm2 start index.js worked. Thanks! Aug 29 at 6:24

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .