Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

How to Resolve ECONNREFUSED Errors on Bitnami Server with Apache2 and PHP-FPM

When running Apache2 with PHP-FPM on a Bitnami server, you might encounter connection issues such as ECONNREFUSED, which can result in website downtime or functionality problems. In this post, we’ll walk through how we can identify and resolve the ECONNREFUSED error.

The Error: connect ECONNREFUSED xx.xxx.xxx.xxx:443

Identifying the Issue

I was experiencing frequent website downtime, so I checked the Apache log files to identify the root cause of the issue. Upon investigating the logs, I found the following message:

(2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /opt/bitnami/php/var/run/www.sock (www-fpm:8000) failed.

This error indicated a PHP-FPM socket issue. To investigate further, I checked the PHP-FPM log file, typically located at:

/opt/bitnami/php/log/php-fpm.log

Reviewing the PHP-FPM Log

While reviewing the PHP-FPM log file, I encountered the following warning:

WARNING: [pool www] server reached pm.max_children setting (10), consider raising it.

The pm.max_children setting controls how many child processes PHP-FPM can handle simultaneously. The issue arose because the PHP-FPM pool had reached its maximum number of child processes, preventing new connections.

Solution: Adjusting the pm.max_children Setting

By increasing the pm.max_children value, you can resolve this issue. Follow the steps below to adjust this setting:

Step 1: Find the PHP-FPM Pool Configuration

The PHP-FPM configuration files are generally located in the following directory:

/opt/bitnami/php/etc/php-fpm.d/

In my case, the relevant configuration file was named www.conf. To edit this file, use your preferred text editor.

#vim /opt/bitnami/php/etc/php-fpm.d/www.conf

Step 2: Locate the pm.max_children Line and increase the value

Once inside the configuration file, find the line that specifies pm.max_children and Adjust this value based on the available resources on your server. In my case, I raised it from 10 to 40:

pm.max_children = 10
increased to 
pm.max_children = 40

Step 3: Save and Exit

After making the changes, save the file and exit the editor:

:wq!

Step 4: Restart PHP-FPM and Apache

To apply the new settings, restart both PHP-FPM and Apache with the following commands:

#/opt/bitnami/ctlscript.sh restart php-fpm
#/opt/bitnami/ctlscript.sh restart apache

Step 5: Monitor the Logs

After restarting, monitor the PHP-FPM and Apache logs for sometime, to ensure there are no more warnings or errors occurring.

Conclusion

By increasing the pm.max_children setting, the server was able to handle more PHP-FPM processes, resolving the ECONNREFUSED error and preventing further downtime.

Make sure to adjust pm.max_children based on your server’s resources and traffic load. This is especially important for high-traffic sites where resource limitations can quickly impact performance make this a proper blog with all the elements

Need help to Resolve ECONNREFUSED Errors on Bitnami Server with Apache2 and PHP-FPM ? Our expert team is here to assist you! Contact us for reliable support and troubleshooting solutions to resolve this error quickly and efficiently.

Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Can't get what you are looking for?

Available 24x7 for emergency support.