Home>Article>Web Front-end> What should I do if pm2 fails to start the node service?

What should I do if pm2 fails to start the node service?

藏色散人
藏色散人 Original
2022-12-29 14:17:52 3993browse

Solution to the failure of pm2 to start the node service: 1. Check the log management node of the PM2 manager to see if it is started successfully; 2. Delete node_modules and clear the buffer, and then reinstall it; 3. Find out the process occupying the port and End it; 4. Just change the port in the uploaded node project.

What should I do if pm2 fails to start the node service?

#The operating environment of this tutorial: Windows 10 system, node v14.15.5 version, Dell G3 computer.

What should I do if pm2 fails to start the node service?

Solve the problem that the node service of Pagoda PM2 is always off when starting the node service and cannot be mapped

I have read a lot of information on the Internet, there are different opinions, and the official has not given a clear answer solution. After many attempts, I encountered two situations, and here are my personal solutions.

First take a screenshot of successful execution

1. Check first Whether the log management node of the PM2 manager is started successfully. If the startup fails, we refresh the web page and you can see the failure mark with a red status.

So I ran the following code to delete node_modules and clear the buffer before reinstalling

rm -rf node_modules npm cache clean --force npm install

2. If the port displays off due to server restart, here we stop the PM2 service first

Run the terminal node app.js here and you can see that the server reports an error because the port is already occupied. I tried to find the process occupying the port and end it, but to no avail, it prompted that the process occupying the port was not found.

Open the corresponding port in the pagoda panel and server security group, and change the port in the uploaded node project (for example, change Change port 3000 to port 3001) and it will run successfully.

In this way, the PM2 manager port is successfully mapped. The only drawback is that the port used will still be occupied after the server is restarted and must be changed before it can be used.

Recommended study: "node.js video tutorial"

The above is the detailed content of What should I do if pm2 fails to start the node service?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn