Home >Operation and Maintenance >Nginx >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 filezhouchang@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 portkill -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!