Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to try to set the worker processes in nginx, but it throws me this error:

nginx: [emerg] "worker_processes" directive is not allowed here in /etc/nginx/sites-enabled/default:1 nginx: configuration file /etc/nginx/nginx.conf test failed

here is my code

worker_processes 4;
worker_rlimit_nofile 8192;
worker_priority 0;
0001 0010 0100 1000;

server {
    server_name --.--.--.---;
    listen 80;

    #root /var/www/devsites/wordpress/;
    root /var/www/devsites/trademob/tm-hp-v2/;

What can I do to fix this issue?

share|improve this question
Which error message ? – Iain Aug 26 '12 at 8:43
up vote 7 down vote accepted

You said that your error message was:

nginx: [emerg] "worker_processes" directive is not allowed here in /etc/nginx/sites-enabled/default:1
nginx: configuration file /etc/nginx/nginx.conf test failed

Place this directive at the top of /etc/nginx/nginx.conf instead of in /etc/nginx/sites-enabled/default. The worker_processes directive is valid only at the top level of the configuration.

The same applies to all the other worker_* directives you've used.

share|improve this answer
Very cool. it works. thanks a lot! – user133529 Aug 26 '12 at 8:51
Thanks! after 2 painful days of figuring out, this solved the issue! – Observer Jul 13 '15 at 20:01

You have a syntax error in your configuration file:

nofile 8192;

It appears that this line got split by accident. It should appear as:

worker_rlimit_nofile 8192;

The same error seems to have happened with the line beginning with worker_cpu_affinity.

Once you fix this, you should get your server back up and running.

share|improve this answer
I have fixed this syntax error, but it doesnt work – user133529 Aug 26 '12 at 8:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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