Nginx: nginx: [warn] load balancing method redefined

Oh Dear monitors your entire site, not just the homepage. We crawl and search for broken pages and mixed content, send alerts when your site is down and notify you on expiring SSL certificates.

Start your free 10 day trial! »

Profile image of Mattias Geniar

Mattias Geniar, April 25, 2013

Follow me on Twitter as @mattiasgeniar

You may receive the following warning when reloading/configtesting an Nginx configuration that uses upstreams.

$ service nginx configtest
nginx: [warn] load balancing method redefined in /etc/nginx/conf.d/upstream.conf:5
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

This can occur when you have a wrong order of upstream variables in your definition, like this:

$ cat upstream.conf 
upstream upstream_name {
  # Use max # keepalive connections
  keepalive 120;
  # Use the backend with least number of connections
  # All upstream members defined below
  server  weight=24;
  server   weight=24;

You can mix keepalive and least_conn, but you should define least_conn before keepalive.

With the wrong order, you’ll get a load balancing method redefined error and Nginx won’t start.

Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.