Nginx: nginx: [warn] load balancing method redefined

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.