How to solve the problem when nginx prompts that the port is occupied when starting

步履不停
Release: 2019-06-25 17:09:28
Original
44525 people have browsed it

How to solve the problem when nginx prompts that the port is occupied when starting

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

nginx: [emerg] still could not bind()

1.The first method: Check the port occupancy and try to kill the process

Enter the command on the port: netstat -ntpl The following will be displayed:

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 127.0.0.1:631 0.0.0.0:*                                                                                                                                                                                                                                                to

# TCP 0 0.0.0.0:80 0.0.0.0:* Listen -

## TCP 0 0 127.0.1.1:53 0.0.0.0:* Listen -

## TCP6 0 0: :1:631                                                                                                                                                                                                                 

#2.

The second solution is to edit the nginx configuration file

zhouchang@zhouchang-CW65S:~$ sudo gedit /etc/nginx/sites-available/default

Just change the following paragraph:

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

to:

listen 80;

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

That’s it

3.

(1)

First check what is occupying port 80

:

fuser -n tcp 80

For example: root@zhouchang-CW65S:/home/zhouchang# fuser -n tcp 80

There will be something like: 80/tcp:       16829 (2)

Kill the occupied port

kill -9 1116

Like this again Just start sudo /etc/init.d/nginx start

For more Nginx related technical articles, please visit

Nginx tutorial

column for learning!

The above is the detailed content of How to solve the problem when nginx prompts that the port is occupied when starting. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!