Nginx Server does not start.

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.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


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).


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 {).


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.