Getting error "500 internal server error" when loading a web page which is an https. The nginx error.log shows "1024 worker_connections are not enough while connecting to upstream"

The website is behind a nginx reverse proxy. It is working without the reverse proxy. Another website behind the proxy is working.

nginx version: nginx/1.16.0

Tried increasing the work connections all the way up to 20480. The configurations seems fine to me. Could be wrong. Here are the configurations files. Reloaded nginx, restarted nginx.


user  nginx;
worker_processes   8;
worker_rlimit_nofile 100480;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;

#Use multiple worker processes
#work_processes auto;

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;

    #disable server tokens
    server_tokens off;



server {
    listen 80;
    server_name example.com www.example.com;
    return 301 https://example.com$request_uri;


server {
   listen 443 ssl;
   server_name example.com www.example.com;

   ssl_certificate         /etc/nginx/cert.pem;
   ssl_certificate_key     /etc/nginx/cert.key;
   ssl_trusted_certificate /etc/nginx/cert.crt;

   location / {
        proxy_pass https://example.com;


   location = /favicon.ico {
        log_not_found off;
        access_log off;


Any assistance is appreciated.


Your server block accepts connections on port 443 and then tries to proxy_pass them back to itself. This results in a loop which eventually makes 1024 or 20480 connections to itself, and then you get the error worker connections are not enough.

To solve the problem, fix the proxy_pass and pass the request to wherever it is actually supposed to go.

  • nicely to See an Infinitiv loop, source=dest – djdomi Aug 11 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.