Solve nginx: [emerg] bind () to [:]: 80 failed (98: Address already in use)

Source: Internet
Author: User

The first choice is to install nginx. /check the error report when configure fails. If necessary libraries are missing and these libraries are installed, ssl pcre may exist (this library is installed by source code, online installation was not successful, prompt not to see this library) and other ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ this is the connection to this library. Download the source code and install it!

Then make

Make install

If the source code is used for installation, the installed directory is in/usr/local/nginx. some of them are started using the source code: sbin/nginx. This program is running in/usr/local/nginx.

For online installation, the default directory after installation is in/etc/init. d/nginx start

If you try it in your browser during the installation process !!

Install nginx on ubuntu10.04. After installation, start nginx and run the following command:

sudo /etc/init.d/nginxstart

Error message:

hankcs@ubuntu:~$ sudo /etc/init.d/nginxstart[sudo] passwordfor hankcs:  * Starting nginx nginx                                                         nginx: [emerg] bind() to [::]:80 failed (98: Address alreadyin use)nginx: [emerg] bind() to [::]:80 failed (98: Address alreadyin use)nginx: [emerg] bind() to [::]:80 failed (98: Address alreadyin use)nginx: [emerg] bind() to [::]:80 failed (98: Address alreadyin use)nginx: [emerg] bind() to [::]:80 failed (98: Address alreadyin use)nginx: [emerg] still could not bind()

I checked the port usage and tried to kill the process:

hankcs@ubuntu:~$ netstat -ntpl(Not all processes can be detected. process information of all non-users is not displayed. To view all information, you must switch to the root user)Activate Internet connection (server only)Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Programnametcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      -              tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -              hankcs@ubuntu:~$ killall -9 nginxNginx: no operation found

In this case, I first searched for the answer in Chinese and found that everyone was loading the script to kill repeated nginx processes. I tried it and found it to be nonsense. So I read the first English page found by Google. A foreigner said that nginx first listened to port 80 of ipv4 and then listened to port 80 of ipv6, so it is occupied again. Even more difficult, you can see that the port is occupied and port 80 is released.

The solution is to edit the nginx configuration file.

hankcs@ubuntu:~$ sudo gedit /etc/nginx/sites-available/default

Modify this section:

listen 80;listen [::]:80 default_server;

Is

listen 80;listen [::]:80 ipv6only=on default_server;

Start nginx and solve it perfectly!

Another possibility is that if nginx is installed on a VM, firefox in the VM may not be connected, but the browser in the host machine can be connected (the premise is that the host machine and the virtual machine can be connected !!!)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.