When Nginx is turned on, the port is occupied and prompts: Address already in use

When Nginx is turned on, the port is occupied and prompts: Address already in use

As shown in the figure:

Check port usage:

sudo netstat -apn | grep 80

View the process occupying the port:

ps -ef | grep 3345

From the results, we can see that port 80 is occupied by Nginx itself. You can kill the process and restart Nginx.

sudo kill -9 3345

sudo netstat -apn | grep 80

After successfully killing the process, start Nginx

Start Nginx successfully. Enter the IP address of the system where Nginx is located in the browser to verify whether Nginx is started successfully.

The following describes how to start, stop, and restart Nginx.

start up

Startup code format: nginx installation directory address -c nginx configuration file address

For example:

[root@LinuxServer sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

stop

There are three ways to stop nginx:

Stop calmly

1. Check the process number

[root@LinuxServer ~]# ps -ef|grep nginx 

2. Kill the process

[root@LinuxServer ~]# kill -QUIT 2072 

Quick Stop

1. Check the process number

[root@LinuxServer ~]# ps -ef|grep nginx 

2. Kill the process

[root@LinuxServer ~]# kill -TERM 2132
or [root@LinuxServer ~]# kill -INT 2132

Force Stop

[root@LinuxServer ~]# pkill -9 nginx

Restart

1. Verify whether the nginx configuration file is correct

Method 1: Enter the nginx installation directory sbin and enter the command ./nginx -t

The following shows that nginx.conf syntax is ok

nginx.conf test is successful

This indicates that the configuration file is correct!

Method 2: Add -t before the startup command -c

2. Restart Nginx service Method 1: Enter the nginx executable directory sbin and enter the command ./nginx -s reload

Method 2: Find the current nginx process number, and then enter the command: kill -HUP process number to restart the nginx service

Summarize

The above is what I introduced to you about the prompt that the port is occupied when starting Nginx: Address already in use. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Detailed explanation of nginx signal set case
  • Introduction to Nginx log management
  • Detailed explanation of CentOS configuration of Nginx official Yum source
  • Install multiple versions of PHP for Nginx on Linux
  • Detailed tutorial on installing PHP and Nginx on Centos7
  • A universal nginx interface to implement reverse proxy configuration
  • Solve the problem of refreshing blank when deploying Vue project nginx to non-root directory
  • How to install Nginx and configure multiple domain names
  • Solution to the problem that docker nginx cannot be accessed after running
  • How to redirect to https through nginx load balancing
  • Nginx signal control

<<:  Implementation of vscode custom vue template

>>:  MySql 5.6.35 winx64 installation detailed tutorial

Recommend

How to use Dayjs to calculate common dates in Vue

When using vue to develop projects, the front end...

Example of implementing QR code scanning effects with CSS3

Online Preview https://jsrun.pro/AafKp/ First loo...

How to use Navicat to export and import mysql database

MySql is a data source we use frequently. It is v...

Docker cleanup environment operation

Start cleaning carefully! List unused volumes doc...

Two ways to clear float in HTML

1. Clear floating method 1 Set the height of the ...

Deploy Nginx+Flask+Mongo application using Docker

Nginx is used as the server, Mongo is used as the...

Detailed explanation of the basic usage of the img image tag in HTML/XHTML

The image tag is used to display an image in a we...

Detailed explanation of MySQL sql99 syntax inner join and non-equivalent join

#Case: Query employee salary levels SELECT salary...

How to use the MySQL authorization command grant

The examples in this article run on MySQL 5.0 and...

JavaScript object-oriented class inheritance case explanation

1. Object-oriented class inheritance In the above...

Installation and configuration method of vue-route routing management

introduce Vue Router is the official routing mana...

CSS multi-level menu implementation code

This is a pretty cool feature that makes web page...

Detailed explanation of Linux mpstat command usage

1. mpstat command 1.1 Command Format mpstat [ -A ...

Detailed explanation of the use of nohup /dev/null 2>&1

nohup command: If you are running a process and y...