Nginx Server does not start.

Posted January 18, 2017 21.1k views

Good afternoon!

I created a server block (Nginx), I did the whole process! Restarted the Nginx and then not returned! The retonor is: Start: nginx [Failed].

Searching I found the error! Accidentally didn’t put the semicolon in charge (/etc/nginx/sites-available/ To try to solve the problem I put the semicolon (;) but even then Nginx does not start! As soon as I deleted the server block that I created, however, the same does not start anymore.

Follow the error appears in the log file:

2017/01/18 13:20:59 [emerg] 19304#19304: unexpected end of file, expecting “;” or “}” in /etc/nginx/sites-enabled/1:9
2017/01/18 13:51:55 [emerg] 19406#19406: unexpected end of file, expecting “;” or “}” in /etc/nginx/sites-enabled/1:9

Can someone help me? Remember, I’m new to Nginx.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
4 answers


Please post the server block and I’ll be more than happy to take a look at it for you. What we need to look at is everything between:

server {

and the closing



The issues are with this server block:

The first issue I’m seeing is with this line:

# Force HTTP to HTTPS
error_page 497 =200 https://$host:22222$request_uri;

The above does not force HTTP to HTTPS, it sets an error page and enforces and internal redirect. It could very well be used to push HTTP to HTTPS, though that’s not what this was actually intended for.

Ideally, you’d setup a server block that looks like this to handle HTTP (on Port 80) redirects to HTTPS (on Port 443).

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    return 301 https://$host$request_uri;

While this isn’t actually what’s causing the issue, it can result in some rather odd logs appearing since the error_page definition isn’t meant for handling redirects to SSL and should be used for it’s actual intended usage.

The actual issue, however, is that this server block is missing the closing } at the end of the file.

Below this block:

  location ~* /vimbadmin/public/(.*) {
    root /var/www/22222/htdocs/vimbadmin/public;
    try_files $uri $uri/  /vimbadmin/public/index.php?$args;

You need another closing }, so it should look like:

  location ~* /vimbadmin/public/(.*) {
    root /var/www/22222/htdocs/vimbadmin/public;
    try_files $uri $uri/  /vimbadmin/public/index.php?$args;

Why? Without that last }, you’re leaving the server { block portion open, so it’s trying to find more configuration that doesn’t exist. Simply add that last closing } and then run:

service nginx reload

and that should get you squared away. If, however, another issue pops up, please let me know and we’ll take look at that error and see what the issue is.

  • Sorry jtittle!

    The environment of the Nano (text editor) is complicated, just forgot to copy the key. In that case the error remains (Nginx does not start).

    Searching in bing I found a few more things in this one command of Nginx which makes an analysis (errors). Running the command (nginx-t) was showing the following:

    root@mail:/# nginx -t
    nginx: [emerg] unexpected end of file, expecting “;” or “}” in /etc/nginx/sites-enabled/1:9
    nginx: configuration file /etc/nginx/nginx.conf test failed

    Follows the nginx file contents:

    I thank you!


The best way to get around the copy and paste issues when using nano would be to login as root to the Droplet using SFTP (using root as your username, your root password, and your Droplet IP – you’ll connect on Port 22).

After you’ve successfully logged in, navigate to your NGINX directory and download the files and then copy and paste from your local text editor.

The reason being is because in the Pastebin you just provided, the issue is with this line:


As it ends with a $ instead of a ; – and that appears to be an issue as the contents of that file was copied from your terminal instance instead of from the file locally.

So you’ll need to download the main file, nginx.conf and the server blocks associated with the sites you’re hosting (i.e. all configuration files starting with server {).

  • Thank you!

    Follow the link with the server blocks and nginx file via SFTP:!9IcTiCYY!-BBQTQy6iubwb51F6acHIKEaETbONqGIKA9HBZ-LcLU

    • @kailtom

      Ok, with a clear view of those files, it doesn’t look like there’s an issue there, so the next place we need to look is at the files you’re including in each of the files.

      would it be possible for you to simply GZIP the entire NGINX directory and let me take a look at all the files? I’ve ran EasyEngine before and normally, their configuration is spot on, but with numerous includes being present and not having access to all the files, it’s hard to see exactly where the issue is.

      Providing me with the entire /etc/nginx directory will give me a look at everything.

      • Good morning!

        Thank you brother for your help! I didn’t before because I was looking at the directory before you forwards. However, this analysis found a file that was generated by the EasyEngine in the directory /etc/nginx/sites-available. Have a file with the name (1). Soon joined the error generated when you run the nginx-t:

        root@mail:/etc/nginx/sites-enabled# nginx -t
        nginx: [emerg] unexpected end of file, expecting “;” or “}” in /etc/nginx/sites-enabled/1:9
        nginx: configuration file /etc/nginx/nginx.conf test failed

        This 1:9 is for the file generated by EasyEngine, just below follows the same content:

        ^[[34mUpdating EasyEngine Database^[(B^[[m
        Error: near line 1: duplicate column name: dbname
        Error: near line 1: duplicate column name: db
        Error: near line 1: duplicate column name: dbpassword
        Error: near line 1: duplicate column name: db
        Error: near line 1: duplicate column name: ishhvm
        Error: near line 1: duplicate column name: is
        Error: near line 1: duplicate column name: php_version

        Now I have a question can I delete this file or do I have to put the; or create block policies?


If the file is not a valid server block and it serves no actual purpose, you should be able to delete it without any issues. If that doesn’t resolve the issues you’re having though, I’d need to take a closer look at the rest of your configuration as there are so many includes in the files, it’s hard to see where the actual error is since NGINX is’t actually giving a file (which is most likely due to the number of includes).