nginx: connect() failed (111: Connection refused) while connecting to upstream

This error message can have several causes. Here are some things you can try to troubleshoot the issue:

  1. Check if the upstream server (e.g., a backend server or a load balancer) is running and reachable. You can try to ping the server to see if it is online.

  2. Make sure that the hostname and port specified in the upstream directive in your NGINX configuration file are correct.

  3. Check if there is a firewall blocking the connection. If you have a firewall configured on your server or on the network, make sure that it is not blocking the connection to the upstream server.

  4. Check the logs for any additional error messages that may provide more context about the problem. The NGINX error log is usually located at /var/log/nginx/error.log.

  5. If you are using a Unix-based operating system, you can also use the lsof command to see if there are any processes listening on the specified port.

  6. If you have recently made changes to your NGINX configuration, double-check the changes to make sure they are correct and restart NGINX to apply the changes.

Watch a course Learn object oriented PHP

I hope these suggestions help you troubleshoot the issue! If you are still having problems, please provide more information about your setup and any additional error messages you are seeing.