How to solve the error 'Port is occupied' during the installation of AnQiCMS?

Calendar 👁️ 84

AnQiCMS as an efficient and flexible content management system is favored by many users for its lightweight features in the Go language and ease of deployment.However, during the installation or startup of AnQiCMS, you may encounter a little detour - an error message that the 'port is already in use.'Don't worry, this is usually a common and easy problem to solve.As an experienced website operation expert, I will deeply analyze this issue for you and provide clear and practical solutions to help you successfully build the AnQiCMS site.

Understanding the meaning of 'port occupied'

To solve a problem, one must first understand its essence. 'Port' is like a 'dedicated channel number' for an application on a server to provide external services. Each application can only use a unique port to provide services at any given time.AnQiCMS starts up and tries to listen on port 8001 by default.If at this time another application on the server (whether it is another web service, database, or other program) is using port 8001, then AnQiCMS will not be able to start successfully, and the system will prompt 'Port is already in use'.This is like two applications trying to use the same phone number at the same time, a conflict is bound to occur.

The reasons for this situation are various: It may be that the AnQiCMS instance you previously started did not close properly, leaving a 'zombie process'; it may also be that other services are installed on the server, which happen to use the same default port; or it may be that you are deploying multiple AnQiCMS sites on the same server without assigning them different ports.

Solution one: Find and terminate the process occupying the port

If a port is occupied by a process you do not need or have forgotten, the most direct method is to find it and terminate it.

ForLinux serverUser, you can uselsofcommands to view the usage of a specific port. For example, to check the usage of port 8001:

lsof -i:8001

After executing this command, the system will list the process information occupying the port, the most critical of which is the "PID" (process ID), which is equivalent to the "ID card number" of this application.

Find the process PID that is using the port, and then you can usekill -9the command to force terminate the process. For example, if the PID is 7621:

kill -9 7621

when executingkill -9Be cautious when issuing commands, ensure you terminate the correct and non-critical process to avoid affecting the normal operation of other critical services on the server.After terminating the process, try to start AnQiCMS again, it usually starts smoothly.

ForWindows userAlthough the operation is slightly different, the principle is similar. You can open the "Task Manager" (by pressingCtrl+Shift+EscShortcut key, or right-click on the taskbar, select 'Details' or 'Processes' tab.Then, you can try to find the related process by the "PID" column (if not displayed, you can right-click on the column title to select add) or directly judge and terminate it according to the process name.When in doubt, you can also use a command-line toolnetstat -ano | findstr :8001Find the PID occupying port 8001 and then end the process with the corresponding PID in Task Manager.

Solution two: Modify the listening port of AnQiCMS.

If the 8001 port is occupied by an important application that cannot be easily closed, or if you plan to run multiple AnQiCMS instances on the same server, it is a wiser choice to modify the listening port of AnQiCMS itself.AnQiCMS has designed high flexibility, allowing you to easily adjust its listening port.

The port configuration of AnQiCMS is stored in the installation directory belowconfig.jsonIn the file. You just need to open this file with a text editor (such as Vim, Nano, Notepad++ etc.) and findportfield and set its default value8001Change it to an unused port number, for example8002/8003Port numbers can even be other numbers you choose, which are not reserved by the system (it is recommended to choose between 1024 and 49151).

{
  "port": 8002, // 将这里的端口号修改为您想要的值
  "database": {
    // ... 其他数据库配置 ...
  },
  // ... 其他配置 ...
}

Saveconfig.jsonAfter the file, restart AnQiCMS.

Special reminder: If you use Nginx or Apache and other web servers for reverse proxy,After modifying the listening port of AnQiCMS, you also need to synchronize the modification of the reverse proxy configuration of the web server. Change the port number in the target URL of the proxy from8001Update toconfig.jsonSet a new port. For example, in the Nginx configurationproxy_pass https://en.anqicms.com;need to be changed toproxy_pass http://127.0.0.1:8002;This ensures that external requests can correctly access your AnQiCMS service through a reverse proxy.

If you deploy AnQiCMS via platforms such as Docker, 1Panel, or aaPanel, these platforms usually provide a graphical interface for managing port mapping and reverse proxy.In these environments, you may need to modify the port exposed by the AnQiCMS container in the container configuration, and update the corresponding website's reverse proxy settings.AnQiCMS Docker installation tutorial (such asdocker-1panel.md/docker-bt.mdDetailed explanation is provided here, you can refer to it.

Multi-site deployment of **practice

AnQiCMS natively supports multi-site management, which is very convenient for users who want to operate multiple websites on a single server. The practice to avoid the error of "port already in use" when deploying multiple sites is:

  1. Allocate a separate port for each AnQiCMS instance:Ensure that each AnQiCMS's settings are unique, whether manually deployed or Docker deployedconfig.jsonofportare unique.
  2. Use reverse proxy for unified management:Configure a separate domain and reverse proxy rule for each AnQiCMS instance using Nginx or Apache, and forward requests from different domains to different port AnQiCMS instances.This way, the user only needs to use the domain name when accessing, without having to care about the specific port number.

By the above method, you can flexibly and effectively handle the 'port already in use' error encountered during the AnQiCMS installation process, ensuring that your website goes online and runs smoothly.The simplicity and efficiency of AnQiCMS are reflected in the ease of use of these details, allowing you to focus more on the operation of the content itself.


Frequently Asked Questions (FAQ)

Q1: Why do I frequently encounter issues with ports being occupied?

A1:Frequent port occupation may have several reasons: one is that you may not have closed the AnQiCMS process normally, causing it to still run in the background and occupy the port;Secondly, you have installed or run multiple services on the server, and there is a port conflict between them;Thirdly, it may attempt to start multiple AnQiCMS instances on the same port due to improper configuration of the automated deployment script or the daemon process.It is recommended to check if the target port is occupied before starting AnQiCMS each time, and make sure to close old or unnecessary AnQiCMS processes.For important production environments, you can set up process supervision (such as systemd) to ensure that AnQiCMS runs only one instance and restarts automatically in the event of a crash.

Q2: After modifying the port of AnQiCMS, do you need to modify other configurations besides reverse proxy?

A2:If you are justconfig.jsonI modified the listening port of AnQiCMS and AnQiCMS runs as a backend service (for example, through Nginx/Apache reverse proxy), so the main thing that needs to be modified is the reverse proxy configuration.In addition, if your server has a firewall, you also need to make sure that the new port is open in the firewall, allowing external access.For multi-site deployment, in addition to modifying the port and reverse proxy, you also need to add and configure a new site in the "Multi-site Management" feature of the AnQiCMS backend, specify the corresponding domain name and database information, etc.

Q3: I don't know which port to choose to avoid conflicts, do you have any recommended port range?

A3:Generally, port numbers can be divided into three categories:

  • Well-known Ports:0 to 1023, typically used by system services and common protocols such as HTTP (80), HTTPS (443), SSH (22), and should be avoided as much as possible.
  • Registered Ports1024 to 49151, these ports can be registered by user applications or services, the default 8001 of AnQiCMS falls within this range.You can choose a relatively late and less commonly used port within this range, such as 8080, 8888, 9000, or simply choose a four or five-digit random number.
  • Dynamic/Private Ports49152 to 65535, usually used for client applications to establish temporary connections.

To avoid conflicts, it is recommended that you choose an unused port within the registration port range (1024-49151). Before selecting a new port, you can uselsof -i:端口号(Linux) ornetstat -ano | findstr :端口号(Windows) to check if the port is already in use, make sure it's safe.

Related articles

What is the specific method for installing and testing AnQiCMS under MacOS?

As an experienced website operations expert, I fully understand the importance of an efficient and stable content management system (CMS) for a corporate website.AnQiCMS (AnQiCMS) stands out in the field of small and medium-sized enterprises and content operations with its lightweight and efficient features in the Go language.Today, let's delve into how to easily install and test AnQiCMS on our commonly used MacOS system, so that everyone can better understand and use this excellent CMS.

2025-11-06

How to correctly stop or close the AnQiCMS application under Windows?

As an experienced website operations expert, I fully understand that in managing a content system, it is not only important to be proficient in using various functions, but also to maintain and manage the application on a daily basis.AnQiCMS (AnQi CMS) brings us a convenient user experience with its efficient and lightweight features based on the Go language in the Windows environment.However, whether for the need of maintenance, upgrade, or temporary debugging, we need to know how to properly and safely stop or close the AnQiCMS application.

2025-11-06

How to test and run AnQiCMS on Windows system for local development and debugging?

As an experienced website operations expert, I fully understand the importance of setting up a development environment locally.It not only allows you to safely test new features and adjust page layouts, but also accelerates content creation and feature iteration without affecting the online website.Today, let's delve deeply into how to easily set up and test run AnQiCMS on a Windows system, and embark on your local development and debugging journey.

2025-11-06

How to compile and install the Go language source code of AnQiCMS, what are the required environment dependencies?

As an experienced website operation expert, I am willing to give you a detailed explanation of the steps for compiling and installing the AnQiCMS (AnQiCMS) Go language source code and the required environment dependencies.AnQi CMS, with its excellent genes in Go language, provides high-performance and high-concurrency content management capabilities. For advanced users who want to deeply customize or deploy in specific environments, source code compilation is undoubtedly an ideal choice.

2025-11-06

How to query and release the port occupied by AnQiCMS or other programs under the Linux system?

AnQiCMS, as an enterprise-level content management system developed based on the Go language, has won the favor of many users with its lightweight and efficient features.When deploying and running AnQiCMS in a Linux environment, we usually specify a listening port for it, such as the default 8001.However, in daily operation and maintenance, we may encounter such situations: AnQiCMS cannot start, indicating that the port is occupied; or the system resources are abnormal, and it is necessary to find and terminate the process occupying a specific port.

2025-11-06

How to change the default administrator account and password after installing AnQiCMS to enhance security?

As an experienced website operations expert, I am well aware of the importance of website security in daily operations, especially in the early stages of system installation, many details may become potential security risks.AnQiCMS is an enterprise-level content management system dedicated to providing efficient, secure, and customizable services, considering security from the beginning of its design.However, the initial settings are often adopted for convenience and use default values, which requires us to take immediate action after installation to ensure the security and stability of the website.

2025-11-06

What are the detailed steps for installing AnQiCMS using 1Panel Docker?

As an experienced website operation expert, I am well aware of the importance of an efficient and easy-to-use content management system for both enterprises and individual operators.AnQiCMS (AnQiCMS) with its high performance brought by the Go language, rich SEO tools, and excellent multi-site management capabilities, has become the first choice of many users.When AnQiCMS encounters a modern server operation and management panel like 1Panel, the ease of deployment has reached a new height.

2025-11-06

How to configure a reverse proxy site for AnQiCMS container deployed with Docker in 1Panel?

As an experienced website operation expert, I am happy to give you a detailed explanation of how to configure reverse proxy sites for AnQiCMS containers deployed in the 1Panel environment, so that your website runs professionally and efficiently. --- ## In 1Panel, configure reverse proxy for AnQiCMS container deployed using Docker: Get your website up professionally!

2025-11-06