The AnQiCMS Operation Manual: Easily resolve the startup dilemma of 'port already in use'

Calendar 👁️ 88

When using AnQiCMS to manage your website, you may occasionally encounter a common but annoying error: 'Port is occupied'.As a content management system developed based on the Go language, known for its efficiency and stability, AnQiCMS usually runs smoothly.However, when it throws this error during startup or restart, many operators may feel at a loss.

Don't worry, this problem is not unique to AnQiCMS, but a challenge that all network service-based applications may encounter.As an experienced website operations expert, I will guide you to deeply understand this error and provide a series of practical diagnostic and solution methods to ensure that your AnQiCMS website can continue to provide stable and reliable services to the outside world.

Understanding 'port already in use': the essence of the problem

Imagine your server as a bustling port, and each application that needs to provide external services must reserve a dedicated 'berth' on the port - this is the network port.Each port can only be occupied by one application at a time.When AnQiCMS attempts to start and listen on a predefined port, if this 'berth' has already been 'berthed' by another program, it cannot bind successfully and reports the error that the 'port is already in use'.

AnQiCMS default usage8001Port, this is the default listening port for its internal service. When you see this error, it usually means one of the following situations:

  1. AnQiCMS process did not stop completely:The previous operation to close or restart AnQiCMS may not have terminated its old processes completely, causing the old processes to still occupy ports in the background.
  2. Other applications are抢占:There may be other services running on your server, unintentionally occupying the AnQiCMS preset8001port (or any custom port you set).
  3. Conflict in multi-instance deployment:When you try to deploy multiple AnQiCMS instances on the same server, a conflict will occur if they are all configured to use the same port.

Understood the basic reasons, we can then proceed to specific diagnosis and resolution.

Diagnose the problem: find out the 'culprit' occupying the port.

The first step in solving the problem is to find out which program is using the port. The diagnostic method varies depending on your server operating system.

Under Linux:

On a Linux server, you can uselsof(list open files) command to view the occupancy of a specified port. For example, if AnQiCMS tries to use8001Port and report an error, you can run it in the terminal:

lsof -i:8001

After executing this command, the system will list the occupation8001Port process information, including process ID (PID), user, command, etc., the most critical information isPIDFor example, the output may be like this:

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

Here12345is occupied8001Port process ID. IfCOMMANDdisplayed asanqicmsit means that the old process of AnQiCMS is at work.

Under Windows environment:

For Windows users, you need to use the 'Task Manager' to find and terminate conflicting processes.

  1. PressCtrl + Shift + Escor right-click on the taskbar to open 'Task Manager'.
  2. Switch to the "Details" or "Processes" tab (which may vary depending on the Windows version).
  3. Look for the nameanqicms.exeprocess.
  4. If found, select it and click the "Finish Task" button at the bottom right.

If you are inlsofor you do not see it directly in the task manageranqicmsProcess, but the port is indeed occupied, so attention should be paid.COMMANDOr is there any suspicious service in the process name.

Solution: let AnQiCMS restart.

Once you locate the "culprit" occupying the port, you can take appropriate measures.

1. Terminate the conflicting process.

Whether on Linux or Windows, the most direct method is to terminate the process occupying the port.

  • Linux users:Using the one obtained in the diagnostic stepsPIDthrough.killCommand forces the process to terminate. For example:

    kill -9 12345
    

    This command will forcibly kill the process with ID:12345After that, you can try to start AnQiCMS again.

  • Windows users:Find in Task Manageranqicms.exeProcess and click 'End Task' to terminate the process.If the port is occupied by other non-AnQiCMS programs, and you confirm that it can be safely terminated, you can also handle it in the same way.

2. Adjust the listening port of AnQiCMS

If the port is occupied by a critical service you do not want to stop, or if you need to run multiple AnQiCMS instances on a single server, it is more appropriate to adjust the listening port of AnQiCMS.

AnQiCMS allows you to modify itsconfig.jsonFiles are used to define different ports. According to the document, when you install multiple AnQiCMS on the same server, you need to assign a different port to each project and edit throughconfig.jsonDefine.

Find the installation directory of your AnQiCMS under.config.jsonFile (usually in the root directory of the project), open it with a text editor, find and modify.portThe value of the field. For example, the default8001is modified to8002:

{
    "name": "Your AnQiCMS Site",
    "port": "8002", // 将这里修改为其他未被占用的端口
    // ... 其他配置项
}

Important reminder:After changing the port, if your AnQiCMS is accessed through Nginx, Apache, and other reverse proxy services, or deployed through Docker containers, you also need to synchronize the update of the reverse proxy configuration to point to the new port.

  • For Docker deployment (such as 1Panel or aaPanel):When installing AnQiCMS in the app store of 1Panel or aaPanel, you will usually be required to set the "server port".The document clearly states: “If you install multiple AnQiCMS containers and set different ports, then fill in different ports for the server, such as 8002, 8003, etc., but still fill in 8001 for the container port.”}]This means you need to ensure that each AnQiCMS container is mapped to a unique port on the host, and the reverse proxy configuration points to this unique host port.config.jsonThen the mapping of the Docker container also needs to be adjusted accordingly (or keep the internal port 8001 of the container unchanged, and only adjust the host mapping port).

3. Port planning for multi-site deployment

AnQiCMS supports multi-site management, but this does not mean that you can arbitrarily copy multiple AnQiCMS program files and run them simultaneously.The document clearly states: "AnQiCMS does not need to duplicate the AnQiCMS code when installing multiple sites on a single server.OneConfigure multi-site in the AnQiCMS instance backend.

If your requirement isMultiple independent AnQiCMS programs(Instead of an AnQiCMS instance managing multiple sites, each independent program instance needs:)

  • Independent port:)As mentioned above, modify)config.jsonTo a unique port.
  • Independent executable file name: start.shIn the script,BINNAMEandBINPATHIt needs to point to different executable files and paths.
  • Independent start/stop script:Create and configure the corresponding for each instance.start.shandstop.shScripts, ensure they manage their own processes and ports.
  • Reverse proxy configuration:Ensure that the Nginx/Apache reverse proxy points to each AnQiCMS instance on its own independent port.

Preventive measures: Avoid recurrence in the future.

It is crucial to develop good operational habits to avoid the repeated occurrence of the "port already in use" error:

  • Use the correct shutdown script:AnQiCMS providesstop.shscript (mentioned in the Docker/Baota installation tutorial), this script is designed to gracefully terminate the AnQiCMS process.Always prefer to stop the service using it rather than directly killing the process, as this can prevent any lingering processes.
  • Plan the port allocation:When deploying a new AnQiCMS instance or service, plan the port usage in advance to avoid port conflicts.
  • Regularly check the service status:Even if there are no errors, use it regularlylsofOr check the critical port with the task manager

Related articles

How to smoothly migrate old data after stopping the AnQiCMS project and redeploying a new version?

In the dynamic journey of website operation, technological iteration and upgrade is the norm.How can you ensure that the data of the old website can be seamlessly migrated to the new environment when you decide to stop the current AnQiCMS project and plan to deploy a completely new and more powerful version, while minimizing business disruption, which is a key challenge that every operator must face.As an experienced website operations expert, I am well aware of the importance of data. Next, I will elaborate on the strategy and steps of this smooth migration based on the characteristics of AnQiCMS and relevant documents.

2025-11-06

What is the relationship between the port configuration in the `config.` file of AnQiCMS and stopping/startup?

In the daily operation and maintenance of AnQi CMS, we often deal with various configuration files.Among them, the `config.` file is undoubtedly one of the 'lifelines' for the operation of AnQiCMS, carrying the core parameters for system startup.Today, as a veteran with many years of experience in website operations, I will delve into the configuration of the `config.` file regarding ports, as well as its inseparable connection with the start and stop of AnQiCMS services.

2025-11-06

How to temporarily disable some features of AnQiCMS without completely stopping it?

## Flexible Control: Disabling Specific AnQiCMS Features Without Interrupting Service As an experienced website operations expert, I know that in our daily work, we often need to fine-tune website features, sometimes to test new modules, sometimes to temporarily disable certain services that are no longer applicable, or to maintain and upgrade without affecting core business.How to temporarily disable some functions of AnQiCMS without completely stopping it?

2025-11-06

What negative impacts will there be on the SEO spider crawling the website after the AnQiCMS service is stopped?

As an experienced website operations expert, I know that every CMS system is crucial for the SEO performance of a website, especially systems like AnQiCMS (AnQiCMS) that integrate a large number of SEO-friendly features from the very beginning.It not only provides the efficiency of content management, but also secures a place for the website in search engines through a series of advanced SEO tools.

2025-11-06

What specific improvements are mentioned in the "elegant startup and restart" of AnQiCMS's changelog?

As an experienced website operations expert, I am well aware of the importance of a stable and efficient CMS system for the operation of a corporate website.In the update log of AnQiCMS (AnQi CMS), we noticed that the feature of "elegant startup and restart of the blog" was proposed in version v1.0.0-alpha, which was then inherited and developed throughout the AnQiCMS system.This seemingly simple description actually contains profound considerations of AnQiCMS in system design and operation experience.In my opinion

2025-11-06

How to confirm that all related processes have exited after stopping the service in the AnQiCMS command-line deployment environment?

AnQiCMS, as an efficient content management system built with Go language, is known for its lightweight and high performance in command-line deployment environments.The characteristics of Go language make AnQiCMS usually compiled into an independent binary file, which simplifies deployment, but also means that we need to clearly understand how to manage its lifecycle.Especially when we need to stop the service, how to ensure that all related background processes have been completely exited, to avoid resource occupation or potential service conflicts, is a critical step to ensure the stable operation of the system and prevent the appearance of 'zombie processes'.###

2025-11-06

After the AnQiCMS project stops, can its static resource files still be accessed through CDN?

AnQiCMS (AnQiCMS) is an efficient and customizable content management system that plays a core role in website operations.Regarding the question of whether the static resource files of the 'AnQiCMS' project can still be accessed via CDN after it stops?This question, as an experienced website operations expert, I am well aware that it involves multiple aspects such as website architecture, content distribution mechanism, and CDN working principles.To accurately answer this question, we need to delve deeply into how AnQiCMS manages static resources and how CDN interacts with these resources from two perspectives. First

2025-11-06

How to set up an automation script for AnQiCMS to stop automatically under certain conditions?

In the daily operation of the website, although we strive for the stability and efficiency of the system, but sometimes for the consideration of maintenance, resource optimization or dealing with emergencies, we need to timely 'let the system take a break.'AnQiCMS is a high-performance content management system built based on the Go language, serving a large number of users with its concise and efficient architecture. However, even such an excellent system still requires careful management on our part as operators.Today, let's discuss how to set up an automated script for AnQiCMS to stop automatically under certain conditions, thus achieving more intelligent and hassle-free operation and maintenance

2025-11-06