Cant restart nginx server

January 17, 2017 11.2k views
Nginx Ubuntu

I don't even know where to begin with fixing this issue. Anyone have any advice?

sudo service nginx restart
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
root@web:/var/www/lyndseearmstrong# journalctl -xe
Jan 17 23:33:07 web sshd[11756]: Connection reset by 221.208.195.106 port 50870 
Jan 17 23:33:07 web sshd[11756]: PAM 4 more authentication failures; logname= ui
Jan 17 23:33:07 web sshd[11756]: PAM service(sshd) ignoring max retries; 5 > 3
Jan 17 23:33:08 web sshd[11760]: fatal: Unable to negotiate with 91.195.103.166 
Jan 17 23:33:09 web sshd[11758]: pam_unix(sshd:auth): authentication failure; lo
Jan 17 23:33:10 web sudo[11762]:     root : TTY=pts/0 ; PWD=/var/www/lyndseearms
Jan 17 23:33:10 web sudo[11762]: pam_unix(sudo:session): session opened for user
Jan 17 23:33:11 web sshd[11758]: Failed password for root from 221.208.195.106 p
Jan 17 23:33:14 web sshd[11758]: Failed password for root from 221.208.195.106 p
Jan 17 23:33:14 web sudo[11762]: pam_unix(sudo:session): session closed for user
Jan 17 23:33:16 web sshd[11758]: Failed password for root from 221.208.195.106 p
Jan 17 23:33:18 web sudo[11964]:     root : TTY=pts/0 ; PWD=/var/www/lyndseearms
Jan 17 23:33:18 web sudo[11964]: pam_unix(sudo:session): session opened for user
Jan 17 23:33:18 web systemd[1]: Stopped A high performance web server and a reve
-- Subject: Unit nginx.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit nginx.service has finished shutting down.
Jan 17 23:33:18 web systemd[1]: Starting A high performance web server and a rev
-- Subject: Unit nginx.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit nginx.service has begun starting up.
Jan 17 23:33:18 web nginx[11971]: nginx: [emerg] "location" directive is not all
Jan 17 23:33:18 web nginx[11971]: nginx: configuration file /etc/nginx/nginx.con
Jan 17 23:33:18 web systemd[1]: nginx.service: Control process exited, code=exit
Jan 17 23:33:18 web sudo[11964]: pam_unix(sudo:session): session closed for user
Jan 17 23:33:18 web systemd[1]: Failed to start A high performance web server an
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit nginx.service has failed.
-- 
-- The result is failed.
Jan 17 23:33:18 web systemd[1]: nginx.service: Unit entered failed state.
Jan 17 23:33:18 web systemd[1]: nginx.service: Failed with result 'exit-code'.
Jan 17 23:33:19 web sshd[11758]: Failed password for root from 221.208.195.106 p
Jan 17 23:33:21 web sshd[11758]: Failed password for root from 221.208.195.106 p
Jan 17 23:33:21 web sshd[11758]: Connection reset by 221.208.195.106 port 51628 
Jan 17 23:33:21 web sshd[11758]: PAM 4 more authentication failures; logname= ui
Jan 17 23:33:21 web sshd[11758]: PAM service(sshd) ignoring max retries; 5 > 3
Jan 17 23:33:25 web sshd[11976]: pam_unix(sshd:auth): authentication failure; lo
Jan 17 23:33:27 web sshd[11976]: Failed password for root from 221.208.195.106 p
Jan 17 23:33:29 web sshd[11976]: Failed password for root from 221.208.195.106 p
lines 1079-1125/1125 (END)

2 Answers

@lyndseearmstrong1

The lines below are where we need to look:

Jan 17 23:33:18 web nginx[11971]: nginx: [emerg] "location" directive is not all
Jan 17 23:33:18 web nginx[11971]: nginx: configuration file /etc/nginx/nginx.con

Although it looks like the output that you copied is missing a few bits from the right side, that's enough to give details on what may be wrong.

Essentially, the above is telling me that there's an issue with this file:

/etc/nginx/nginx.conf

... or one of the server blocks that you're including in to it. So we need to check that file and your server block configuration (the blocks starting with server { for your sites).

If you can post both of those, I can take a look at things for you.

  • server {
           listen 80;
           root /var/www/lyndseearmstrong/frontend/app/;
           index index.html index.htm;
    
           server_name lyndseearmstrong.com;
    
           location /api/ {
                   proxy_pass http://127.0.0.1:8001/;
                   proxy_redirect    off;
                   proxy_set_header  Host            $host;
                   proxy_set_header  X-Real-IP        $remote_addr;
                   proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
           }
    
           location /admin/ {
                   proxy_pass http://127.0.0.1:8001/admin/;
                   proxy_redirect    off;
                   proxy_set_header  Host            $host;
                   proxy_set_header  X-Real-IP        $remote_addr;
                   proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
           }
    }
    
    server {
           listen 80;
    
           root /var/www/lyndseearmstrong /frontendDev/app/;
           index index.html index.htm;
    
           server_name dev.lyndseearmstrong.com;
    
           location /api/ {
                   proxy_pass http://127.0.0.1:8001/;
                   proxy_redirect    off;
                   proxy_set_header  Host            $host;
                   proxy_set_header  X-Real-IP        $remote_addr;
                   proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
           }
    
           location /admin/ {
                   proxy_pass http://127.0.0.1:8001/admin/;
                   proxy_redirect    off;
                   proxy_set_header  Host            $host;
                   proxy_set_header  X-Real-IP        $remote_addr;
                   proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
           }
    }
    server {
           listen 8000;
           location / {
                   proxy_pass http://127.0.0.1:8001/;
                   proxy_redirect    off;
                   proxy_set_header  Host            $host;
                   proxy_set_header  X-Real-IP        $remote_addr;
                   proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
           }
    }
    
    
    

I had the same error but mine was i forgot to put the semi colon after the proxy_pass line

Have another answer? Share your knowledge.