1

Topic: Problem Nginx

==== Required information ====
- iRedMail version (check /etc/iredmail-release): Latest, installed yesterday (9.0.6)
- Linux/BSD distribution name and version: VPS running debian 8 (wheezie)
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL (checked that during installation)
- Web server (Apache or Nginx): Not sure, i've seen both installed on my server.
- Manage mail accounts with iRedAdmin-Pro? none
- Related log if you're reporting an issue:


Hello, I installed Iredmail and at the end I have had an error. Now my nginx is saying it has an error on startup. Here is the error I have :

Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
root@vps359601:~# /etc/init.d/nginx restart
[....] Restarting nginx (via systemctl): nginx.serviceJob for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
 failed!

The status of nginx :

root@vps359601:~# /etc/init.d/nginx status
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
   Active: failed (Result: exit-code) since Fri 2017-01-27 01:24:07 CET; 53s ago
  Process: 17514 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 17513 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)

Jan 27 01:24:06 vps359601.ovh.net nginx[17514]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jan 27 01:24:06 vps359601.ovh.net nginx[17514]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jan 27 01:24:06 vps359601.ovh.net nginx[17514]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jan 27 01:24:06 vps359601.ovh.net nginx[17514]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jan 27 01:24:07 vps359601.ovh.net nginx[17514]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jan 27 01:24:07 vps359601.ovh.net nginx[17514]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jan 27 01:24:07 vps359601.ovh.net systemd[1]: nginx.service: control process exited, code=exited status=1
Jan 27 01:24:07 vps359601.ovh.net systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Jan 27 01:24:07 vps359601.ovh.net systemd[1]: Unit nginx.service entered failed state.
Jan 27 01:24:07 vps359601.ovh.net nginx[17514]: nginx: [emerg] still could not bind()

And here is my /etc/nginx/nginx.conf file :

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


#mail {
#    # See sample authentication script at:
#    # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#    # auth_http localhost/auth.php;
#    # pop3_capabilities "TOP" "USER";
#    # imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#    server {
#        listen     localhost:110;
#        protocol   pop3;
#        proxy      on;
#    }
# 
#    server {
#        listen     localhost:143;
#        protocol   imap;
#        proxy      on;
#    }
#}

Thanks for your help!

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Problem Nginx

alpha132 wrote:

Jan 27 01:24:06 vps359601.ovh.net nginx[17514]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

It says port 80 was using by other program. You can check which program is listening on port 80:

lsof -i :80

3

Re: Problem Nginx

Hello. I pasted the command, here is the result :

COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
apache2 20694     root    4u  IPv6  58167      0t0  TCP *:http (LISTEN)
apache2 21976 www-data    4u  IPv6  58167      0t0  TCP *:http (LISTEN)
apache2 21978 www-data    4u  IPv6  58167      0t0  TCP *:http (LISTEN)
apache2 21979 www-data    4u  IPv6  58167      0t0  TCP *:http (LISTEN)
apache2 21980 www-data    4u  IPv6  58167      0t0  TCP *:http (LISTEN)
apache2 21981 www-data    4u  IPv6  58167      0t0  TCP *:http (LISTEN)
apache2 22453 www-data    4u  IPv6  58167      0t0  TCP *:http (LISTEN)
apache2 23072 www-data    4u  IPv6  58167      0t0  TCP *:http (LISTEN)
apache2 23073 www-data    4u  IPv6  58167      0t0  TCP *:http (LISTEN)
apache2 23074 www-data    4u  IPv6  58167      0t0  TCP *:http (LISTEN)

apache2 is used for my website wordpress, which I am hosting on the vps debian. Will it be affected if I change apache port? How do I change apache port?

4

Re: Problem Nginx

If you already running Apache as web server, why run another Nginx?

5

Re: Problem Nginx

root@silver:/var/log/nginx# lsof -i :80
COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   1854     root    7u  IPv4  17845      0t0  TCP *:http (LISTEN)
nginx   1855 www-data    7u  IPv4  17845      0t0  TCP *:http (LISTEN)
python  3002  netdata    3u  IPv4  23697      0t0  TCP xxx.yyy.zzz:57924->xxx.yyy.zzz:http (CLOSE_WAIT)
python  3002  netdata    4u  IPv4  22158      0t0  TCP xxx.yyy.zzz:57928->xxx.yyy.zzz:http (CLOSE_WAIT)
python  3002  netdata    7u  IPv4  22201      0t0  TCP xxx.yyy.zzz:57996->xxx.yyy.zzz:http (CLOSE_WAIT)
python  3002  netdata    8u  IPv4  22205      0t0  TCP xxx.yyy.zzz:58000->xxx.yyy.zzz:http (CLOSE_WAIT)
python  3002  netdata    9u  IPv4  22211      0t0  TCP xxx.yyy.zzz:58008->xxx.yyy.zzz:http (CLOSE_WAIT)
python  3002  netdata   10u  IPv4  22215      0t0  TCP xxx.yyy.zzz:58012->xxx.yyy.zzz:http (CLOSE_WAIT)
python  3002  netdata   11u  IPv4  22224      0t0  TCP xxx.yyy.zzz:58020->xxx.yyy.zzz:http (CLOSE_WAIT)
python  3002  netdata   13u  IPv4  22228      0t0  TCP xxx.yyy.zzz:58024->xxx.yyy.zzz:http (CLOSE_WAIT)
root@silver:/var/log/nginx# lsof -i :443
COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   1854     root    6u  IPv4  17844      0t0  TCP *:https (LISTEN)
nginx   1855 www-data    6u  IPv4  17844      0t0  TCP *:https (LISTEN)