Error while running nginx


Hello, I am running Edx instance on Azure VM. I have attached the DNS to my edx instance. I want to get ssl certificate. So I was trying to get this.

  1. First I added fully qualified Domain name in LMS configuration file. as
  2. Then I ran First 5 commands properly then,
  3. Then I run cmd: sudo certbot --authenticator standalone --installer nginx --pre-hook “service nginx stop” --post-hook “service nginx start”

But I got error as

Error while running nginx -c /etc/nginx/nginx.conf -t.

nginx: [emerg] unknown directive “” in /etc/nginx/sites-enabled/lms:12

nginx: configuration file /etc/nginx/nginx.conf test failed

It also shows : The nginx plugin is not working; there may be problems with your existing configuration.

The error was: MisconfigurationError(‘Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] unknown directive “” in /etc/nginx/sites-enabled/lms:12\nnginx: configuration file /etc/nginx/nginx.conf test failed\n’,)

There seems to be problem with nginx server. Please guide me to install my ssl certification



Can you share us your config file at /etc/nginx/sites-enabled/lms ? (Upload it to a pastebin or gist would be best)

Thank you


Hello Friend,

Please find the pastebin URL which has my LMS config file.

Please suggest me the solution.



You would need server_name before the domain name for Nginx to work.

server {
  # LMS configuration file for nginx, templated by ansible
  server_name   #This is my domain

Thank you


Okay Thanks Stevenzhu.
So Do I need to add my Azure VM name there in place of Server_name?



Just add the server_name before your domain.

(Consider this definition for server_name

Server names are defined using the server_name directive and determine which server block is used for a given request. See also “How nginx processes a request”. They may be defined using exact names, wildcard names, or regular expressions:


In short & my opinion, server_name specify the domain this Nginx server would respond to request. You can’t just copy and paste your domain name in the vHost without server_name directive )


Many Thanks Stevenzhu…


Hi, I got the certificate and all. But just one query: In my LMS file, there is no line like this:
#listen 80;

(Anyways it is to be commented/deleted)
But there are two lines below as:

listen 80 default_server;
return 404; # managed by Certbot

What Do I have to do with these lines?



I don’t really understand why there’s an return 404… However, if you only have one vHosts, the default_server doesn’t quite matters.

(It means if theer are other domains not registered on vHost, the server is going to display this domain…)

The default server also going to be use in sni settings. (The default server will always be the major / main certificate served)

Thank you


Thanks buddy.

Now there is problem with my nginx. Although nginx is installed. When I run: sudo systemctl restart nginx
It says:

mlopenedx@MillionEdx:~$ sudo systemctl restart nginx
Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.



Check the two commands:

  1. systemctl status Nginx -l
  2. nginx -t

And see what’s the output…

Then you can probably figure out the error :slight_smile:


Hi, Below is output.

mlopenedx@MillionEdx:~$ systemctl status Nginx -l
● Nginx.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)

Why is it saying nginx Not-Found. Do I need to re install or update nginx. What is this problem. Please guide me. Appreciate your help.

mlopenedx@MillionEdx:~$ sudo nginx -t
nginx: [warn] server name “/server/server-error.html” has suspicious symbols in /etc/nginx/sites-enabled/lms:17
nginx: [warn] server name “/server/server-error.html” has suspicious symbols in /etc/nginx/sites-enabled/lms:233
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Also when I see LMS17 & 233 the line in LMS It is:

error_page 504 /server/server-error.html;



I’m just curious…

On server name (the LMS vHost ), do you put a ; after the domain?

Should be server_name;

Thank you


Unix environments are always case-sensitive, distinguishing between capital letters and lower-case letters. Most software and directory names in a Unix environment are conventionally written in lower-case.

If you literally wrote systemctl status Nginx then you were referring to a nonexistent Nginx service which is different from the nginx service.

Even software that is written with a brand name with a capital letter, such as Certbot, is most often installed and referred to in lower-case in command lines, like certbot renew.


Hello schoen,
Thanks. But now I am not able to browse LMS on my IP address. It is giving error:
404 Not Found nginx
I saw error log file from : /var/log/nginx/error.log
It is as below:

2018/06/13 15:56:20 [emerg] 2394#2394: unknown directive "" in /etc/nginx/sites-enabled/lms:12
2018/06/13 16:29:09 [warn] 34521#34521: server name "/server/server-error.html" has suspicious symbols in /etc/nginx/sites-enabled/lms:13
2018/06/13 16:30:25 [warn] 35298#35298: server name "/server/server-error.html" has suspicious symbols in /etc/nginx/sites-enabled/lms:13
2018/06/13 16:30:25 [notice] 35298#35298: signal process started
2018/06/13 16:30:25 [error] 35298#35298: invalid PID number "" in "/var/run/"
2018/06/13 16:30:25 [warn] 35299#35299: server name "/server/server-error.html" has suspicious symbols in /etc/nginx/sites-enabled/lms:13
2018/06/13 16:31:24 [warn] 36056#36056: server name "/server/server-error.html" has suspicious symbols in /etc/nginx/sites-enabled/lms:13
2018/06/13 16:31:24 [warn] 36056#36056: server name "/server/server-error.html" has suspicious symbols in /etc/nginx/sites-enabled/lms:226
2018/06/13 16:31:24 [notice] 36056#36056: signal process started
2018/06/13 17:21:30 [warn] 73552#73552: server name "/server/server-error.html" has suspicious symbols in /etc/nginx/sites-enabled/lms:17
2018/06/13 17:21:30 [warn] 73552#73552: server name "/server/server-error.html" has suspicious symbols in /etc/nginx/sites-enabled/lms:233
2018/06/13 17:21:30 [emerg] 73552#73552: bind() to failed (98: Address already in use)

Can you help me solve the error?


Please post the contents of the file /etc/nginx/sites-enabled/lms here again. It’s clear that it contains some kind of formatting error.


Hello schoen, please find below LMS file Content:

And advise me.


You are missing the semicolon character ; at the end of line 13.


This is the same problem that @stevenzhu noted above

Error while running nginx

but it seems that you haven’t fixed it yet.


Okay That is because in document there is no semi colon.
I will try now. Thanks.