0

I have tried to change the port in which nginx listens for from 80 to 6000. However I get this when I try to restart it.

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

This is my sites-enabled setup.

server {
    listen   6000; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

    root /var/www/mywebsite.co/html;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    server_name mywebsite.co www.website.co;

    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;
    }
}

I have a feeling the 0.0.0.0:6000 should be the ip address in which the server is held on e.g 192.168.1.3:6000 however I am not sure how to do this. Any help would be appreciated thanks.

1

Try changing #listen [::]:80 default_server ipv6only=on; ## listen for ipv6

To: listen [::]:6000 ipv6only=on default_server;

If that doesn't work, you could netstat -natp | grep 6000 to see more info.

  • Thanks netstat -natp | grep 6000 helped. I found I was using another service with this port. – Stephen Fox Jan 14 '15 at 20:08
1

TCP port 6000 is the port normally used by the X Window system. If you're on a UNIX-ish system that's not a Mac and you're using a GUI, then port 6000 is most likely already in use by the X server running on the local machine. That's why nginx is failing to bind to it.

  • Yeah I found I was using another service with that port. Issue Resolved, Thanks. – Stephen Fox Jan 14 '15 at 20:07
0

to find out whats running on a well known port (ie tcp/6000), you could do something like, as root:

for i in $(grep [WELLKNOWNPORT] /etc/services|awk '{print $1}'); do lsof|grep $i; done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.