I am developing a django powered application using nginx
and gunicorn
.
Everything was fine, until today which i tried to restart nginx
which failed. so I tested it with sudo nginx -t
command and I got this error.
nginx: [emerg] host not found in "localhost:8004" of the "listen" directive in
/etc/nginx/sites-enabled/808:2
nginx: configuration file /etc/nginx/nginx.conf test failed
this is 808
config file contents:
server {
listen localhost:8004;
error_log /var/www/html/burger808/error.log;
location / {
proxy_pass http://127.0.0.1:8005;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
location /static/ {
autoindex on;
alias /var/www/html/burger808/burger808/static/;
}
location /media/ {
autoindex on;
alias /var/www/html/burger808/burger808/media/;
}
}
I thought it might be some conflicting over 8004
port. So i checked the other congfig files and there were no conflictings.
I wonder what could've caused this error?
No need of localhost:8004
.Only need is
listen 8004;
My problem was that I was trying to add custom host "my-website.test" to the nginx config.
What I had to do first is to modify my /etc/hosts
and add "my-website.test" there.
After that my nginx ran successfully.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With