Home >Operation and Maintenance >Nginx >How to check if nginx port is occupied
First check the nginx configuration
Check which ports are used in the nginx configuration and whether port numbers commonly used by other programs are used. Generally speaking, nginx is used as an http server or reverse proxy server. The most commonly used ports are http port 80 and https port 433. If other ports are used in the configuration, especially those below 1024, it is recommended to modify the port configuration. (Recommended learning: nginx tutorial)
Find the process occupying the port
If you confirm that the nginx port configuration is correct, then change the current Find the process occupying the port. Modern operating systems can query process information based on port numbers. Taking Linux as an example, you can use the lsof or netstat command to query the processes occupying the port.
Use the lsof command to query the port occupying process
Use the netstat command to query the process occupying the port
Resolve the conflict according to the actual situation
After finding the process occupying the port, first determine whether the process is the same as the one occupying the port. nginx relationships and priorities.
If this process is nginx itself, it means that nginx has already been started and nginx cannot be started repeatedly;
If this process is a process that nginx wants to proxy or does not provide services to the outside world, you can modify this process. Configuration, let it use other ports, and then restart;
If this process has provided services to the outside world and cannot be modified, you need to modify the nginx related configuration to let nginx use other ports;
If This is a process you don't recognize, so be careful. The server may be under attack and needs to be killed and fully disinfected.
The above is the detailed content of How to check if nginx port is occupied. For more information, please follow other related articles on the PHP Chinese website!