Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx not running with no error message

Tags:

nginx

I am trying to start my nginx server. When I type "$> /etc/init.d/nginx start", I have a message appearing "Starting nginx:", and then nothing happens. There is no error message, and when I check the status of nginx I see that it is not running.

Here is my /etc/nginx/nginx.conf file:

worker_processes  4; daemon off;  error_log  /home/vincent/tmp/nginx.log;  pid        /home/vincent/tmp/nginx.pid;   events {     worker_connections  1024; }   http { default_type  application/octet-stream;  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                   '$status $body_bytes_sent "$http_referer" '                   '"$http_user_agent" "$http_x_forwarded_for"';  access_log  /home/vincent/tmp/access.log  main;  sendfile        on;  keepalive_timeout  65;  include /etc/nginx/site-enabled/*; 

}

And here is my /etc/nginx/sites-available/default file :

server {   listen       80;   server_name technical-test.neo9.lan;     access_log  /var/log/nginx/technical-test.neo9.lan.log main;    set $home /home/vincent;    location / {     alias $home/neo9/web/app/;     index  index.html;   }    location /api/ {     rewrite  ^/api/(.*)$  /$1 break;     proxy_pass http://localhost:1234;     proxy_set_header Host $host;     proxy_set_header X-Real-IP $remote_addr;   } } 
like image 326
user2618928 Avatar asked Jul 25 '13 13:07

user2618928


People also ask

Why is nginx not running?

If nginx does not start, look for the reason in the error log file logs\error. log . If the log file has not been created, the reason for this should be reported in the Windows Event Log. If an error page is displayed instead of the expected page, also look for the reason in the logs\error.


2 Answers

First, always sudo nginx -t to verify your config files are good.

I ran into the same problem. The reason I had the issue was twofold. First, I had accidentally copied a log file into my site-enabled folder. I deleted the log file and made sure that all the files in sites-enabled were proper nginx site configs. I also noticed two of my virtual hosts were listening for the same domain. So I made sure that each of my virtual hosts had unique domain names.

sudo service nginx restart 

Then it worked.

like image 120
badmadrad Avatar answered Sep 17 '22 02:09

badmadrad


You should probably check for errors in /var/log/nginx/error.log.

In my case I did no add the port for ipv6. You should also do this (in case you are running nginx on a port other than 80): listen [::]:8000 default_server ipv6only=on;

like image 42
Arvind Bhardwaj Avatar answered Sep 20 '22 02:09

Arvind Bhardwaj