我正在使用nginx和gunicorn开发一个django支持的应用程序。一切都很好,直到今天,我尝试重新启动nginx,但失败了。所以我用sudo nginx -t命令对它进行了测试,得到了这个错误。
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这是808配置文件的内容:
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/;
}
}我想这可能是8004端口上的一些冲突。所以我检查了其他的congfig文件,没有冲突。
我想知道是什么导致了这个错误?
发布于 2015-07-26 14:19:59
这个smart answer是我的解决方案
我假设您正在运行一个Linux,并且使用gEdit来编辑您的文件。在
/etc/nginx/sites-enabled中,它可能留下了一个临时文件,例如default~(查看~)。删除此文件,它将解决您的问题。
发布于 2015-07-26 14:15:12
不需要localhost:8004.Only需要的是
listen 8004;发布于 2020-12-10 07:19:37
我的问题是,我试图在nginx配置中添加自定义主机"my-website.test“。
我首先要做的是修改我的/etc/hosts并在那里添加"my-website.test“。
从那以后,我的nginx跑得很成功。
https://stackoverflow.com/questions/31637904
复制相似问题