G
G
Grigory2017-02-28 17:36:04
Nginx
Grigory, 2017-02-28 17:36:04

Why can Nginx ignore port settings?

Good evening! I searched for the cause of the problem for a long time, experimented, but did not find a solution. I ask for help from experienced colleagues)
On the same server (Debian 7), apache2 and nginx are running simultaneously. They work in parallel and independently of each other (not proxying).
Problem: at startup, nginx tries to cling to the 80th port , which is already occupied by apache, although in all the nginx-related configs I know, the 80th port has been replaced with others.
In one listen 8000 config, in another listen 8009,
the 80th port was removed from everywhere, but when nginx starts, it writes:

Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

Here are the configs:
default from /etc/nginx/sites-enabled
server {
        listen   8009; ## listen for ipv4; this line is default and implied
        listen   [::]:8009 default_server ipv6only=on; ## listen for ipv6

        root /usr/share/nginx/www;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name localhost;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.html;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow 127.0.0.1;
                allow ::1;
                deny all;
        }
}

/etc/nginx/sites-enabled/mysite_nginx.conf -
single site config served by nginx
# mysite_nginx.conf

upstream django {
    server unix:///var/www/django1/django1/mysite.sock; 
    #server 127.0.0.1:8001; 
}


server {

    listen      8000;

    server_name     XXX.XXX.XXX.XXX; 
    charset     utf-8;


    client_max_body_size 75M;  


    location /media  {
        alias /var/www/django1media;  
    }

    location /static {
        alias /var/www/django1static;  

    }


    location / {
        uwsgi_pass  django;
        include     /var/www/django1/django1/uwsgi_params; 
    }
}

What could be the problem? What and where to change so that nginx stops trying to become on port 80, and follows the settings from the configs? Thanks in advance!)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
lolowin32, 2017-03-01
@gpetrov

delete the default.save file from /etc/nginx/sites-enabled , and put the new settings in the default file , then try to run

M
MustDie95, 2017-02-28
@MustDie95

Look at all the include directives from the main nginx.conf.
Perhaps they are connected there not only from /etc/nginx/sites-enabled

V
Vladislav Istomin, 2020-02-17
@vladsold

"Address already in use" i.e. the port is busy. If you put in the settings for example 8080 then everything will start. Or see who is on port 80 and disable this service

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question