Nginx: [emerg] bind () to [:]: 80 failed (98: Address already in use) error solution

Source: Internet
Author: User
Tags bind

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

The code is as follows: Copy code

Sudo/etc/init. d/nginx start

The error message is as follows:

Hankcs @ ubuntu :~ $ Sudo/etc/init. d/nginx start
[Sudo] password for hankcs:
* Starting nginx: [emerg] bind () to [:]: 80 failed (98: Address already in use)
Nginx: [emerg] bind () to [:]: 80 failed (98: Address already in use)
Nginx: [emerg] bind () to [:]: 80 failed (98: Address already in use)
Nginx: [emerg] bind () to [:]: 80 failed (98: Address already in use)
Nginx: [emerg] bind () to [:]: 80 failed (98: Address already in use)
Nginx: [emerg] still cocould not bind ()

Problem Description: The address is already in use. The nginx service may be stuck, causing Port occupation. This error occurs.


Solution:

First, use lsof: 80 to check which program occupies port 80. Lsof returns the following results:

The code is as follows: Copy code


Hankcs @ ubuntu :~ $ Netstat-ntpl

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
Tcp 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 nginx

Nginx: no operation found

Nginx configuration file

The code is as follows: Copy code

Hankcs @ ubuntu :~ $ Sudo gedit/etc/nginx/sites-available/default

Modify this section:

Listen 80;
Listen [:]: 80 default_server;

Is

Listen 80;
Listen [:]: 80 listen 6only = on default_server;

Start nginx and solve it perfectly!

If you find the operation, we can perform the following operations:

It was found that it was an nginx program, so we dropped the nginx service k and restarted the service .. The command is as follows:

The code is as follows: Copy code

Kill-9 3274
Kill-9 3547

Service nginx start
Starting nginx:

Add an 80 occupation solution

Cause: port 80 is occupied. Run the "lsof-I: 80" command to check which program occupies port 80. My result shows that port 80 is occupied by apache.
[Root @ localhost html] # lsof-I: 80
Command pid user fd type device size/OFF NODE NAME
Httpd 1203 root 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1217 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1218 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1219 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1220 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1221 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1222 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1223 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1224 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1285 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1830 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1871 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1872 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1873 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1874 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1875 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1876 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1877 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN) solution: handle the problem according to your own situation, I stopped apache and uninstalled it directly (because apache is no longer used). I restarted nginx.

 

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.