As an experienced website operations expert, I know that AnQiCMS excels in providing efficient and customizable content management solutions.AnQiCMS with its high concurrency features and concise and efficient architecture in Go language, brings great convenience to many small and medium-sized enterprises and content operation teams.However, even the most excellent system is bound to encounter some "small setbacks" during operation, such as the sudden unavailability of the background, which often leaves operators in a hurry.

Today, let's delve deeply into a common culprit for the inaccessibility of the AnQiCMS backend on a Linux server - port occupation, and also introduce how to systematically check and solve this problem.


Why do you suspect port occupation first when AnQiCMS background 'disconnected'?

Imagine that your AnQiCMS website front-end access is normal, and content updates are carried out as scheduled, but when you try to log in to the back-end management interface, the browser shows "Unable to access this website" or "Connection rejected".This is often the first focus when troubleshooting, besides factors like firewalls and network configurations.

AnQiCMS as an independent application, needs to listen on a specific port to provide services. According to AnQiCMS's default configuration, this port is usually8001.If this port is preempted by another process on the server, or if the old process of AnQiCMS fails to close properly leading to port conflict, the new AnQiCMS service will not be able to start or respond to requests normally, resulting in the inability to access the background.Since AnQiCMS is developed in Go language, its service process usually runs in the form of a single executable file, port conflict is a very common problem for such applications in deployment and maintenance.

Unraveling: How to check port occupancy on a Linux server?

In Linux systems, we have a very handy 'detective tool' for checking port occupation situations.lsofa command.lsofThe full name is “List Open Files”, it can list the files currently open in the system, and network connections in Linux are also considered as files, so through it we can view which processes are using which ports.

To check if a specific port is occupied, you can enter the following command in the terminal:

lsof -i:<端口号>

For example, if your AnQiCMS is running by default on8001You will enter:

lsof -i:8001

After executing the command, the system will return information similar to the following:

COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
anqicms    7621   root    3u  IPv4  70347      0t0  TCP *:8001 (LISTEN)

This output information reveals the key issue:

  • COMMAND: The name of the process using this port is, here isanqicms.
  • PID: 进程的唯一标识符,即进程ID。在这个例子中是7621.
  • USER: 运行该进程的用户。
  • FD: 文件描述符。
  • TYPE: 文件类型。
  • DEVICE: 设备号。
  • SIZE/OFF: 文件大小或偏移量。
  • NODE: Node number.
  • NAME: Detailed information of network connection,*:8001 (LISTEN)indicating that the process is listening on all IP addresses,8001port.

Iflsofthe command has output, andCOMMANDIf the display does not show the AnQiCMS process you are currently expecting to run (such as a leftover old process, or other completely unrelated services), congratulations, you have found the 'suspect' that is occupying the port. If there is no output, it means8001Port is idle, then the problem may be in other aspects, such as firewall configuration, AnQiCMS service not started or failed to start, etc.

Resolve port conflict: "Evict" or "Relocate"

After finding the process occupying the port, there are usually two solutions:

  1. "Evict": Terminate the process occupying the portThis is the most direct solution. You can refer tolsofthe command output ofPIDUsekillcommand to force terminate the process.

    kill -9 7621
    

    Here are the7621abovelsofthe command output inanqicmsthe process ofPID.kill -9It sends a forced termination signal to ensure the process is immediately closed.After terminating the process occupying the port, you can try to restart your AnQiCMS service.If the port occupation is caused by the residue of old processes, this usually solves the problem.

  2. “Moving”:Modify the listening port of AnQiCMSIf you find that the process occupying the port is an important system service, or if you want to run multiple AnQiCMS instances on a single server, then modifying the AnQiCMS listening port is a more secure and long-term solution. AnQiCMS's running port is usually configured in the root directory of the project.config.jsonFile within (the specific location may vary depending on your deployment method, but is commonly found in the application main directory). You need to edit this file, findportRelated configuration items, change it to an unused port currently, for example,8002/8003ect. Modifyconfig.jsonAfter the file, save and restart the AnQiCMS service.Also, if your website uses Nginx or Apache and other reverse proxies, please be sure to synchronize the modification of the reverse proxy configuration, pointing the proxy target port to the new listening port of AnQiCMS. This way, external access can be routed to AnQiCMS normally.

Troubleshooting is not just about ports: some additional considerations

Although port occupation is a common problem, troubleshooting is a systematic process. If the port occupation issue has been ruled out but the background is still inaccessible, there are still some other directions that can be quickly checked:

  • Firewall settings:Check the firewall of the server (such asfirewalldorufwIs it allowed to access the port that AnQiCMS is listening on externally. If the port is blocked by the firewall, external connections will not be possible even if the service is running normally.
  • Web server configurationIf you use Nginx or Apache and other web servers as reverse proxies, please check if their configuration files are correctly pointing to the listening port of AnQiCMS, and whether the web server itself is running normally.
  • AnQiCMS service status:Did AnQiCMS service really started? You can useps aux | grep anqicmsCommand to check if there is a process running related to AnQiCMS. If not, you need to check the startup script or log file to find out the cause of the failure.
  • AnQiCMS log fileAnQiCMS usually generates run logs.Check its log file (the specific location depends on your deployment), which can help you find error information inside the program. This is crucial for troubleshooting.


Common Questions (FAQ)

Q1: Why does the AnQiCMS backend suddenly become inaccessible?A1: AnQiCMS backend suddenly cannot be accessed, there are many common reasons. First, it may bePort is occupied,导致AnQiCMS服务无法启动或响应。其次,可能是服务器防火墙配置问题,阻止了外部对AnQiCMS端口的访问。此外,Web server (such as Nginx/Apache) reverse proxy configuration errorAnQiCMSService itself stops or fails to start abnormallyEven lower-level file permissions and database connection issues can cause the background to be inaccessible. Compatibility issues may also be introduced after system updates or configuration changes.

Q2: Besides port occupation, what are some common configuration errors that can lead to AnQiCMS backend unavailability?A2: In addition to port occupation, there are several common configuration errors worth noting. The first isThe listening port of AnQiCMS firewall is not open,导致external request cannot be reached. The second isReverse proxy configuration error of the web server (Nginx/Apache)For example, the proxy address or port is incorrect, or the necessary request header settings are missing. Third, if AnQiCMS is configured withIndependent domain name for the admin panel(In系统设置中),但该域名未正确解析或未在Web服务器上配置相应的SSL证书/反向代理,也会导致后台无法访问。最后,如果数据库连接信息(auto)config.jsonIf the content or the initial configuration changes or is incorrect, AnQiCMS will also fail to run properly.

**Q3: If I change the port of AnQiCMS (in `config.