本文最后更新于:4 个月前

记录一次使用Hexo来,第一次遇到的问题。

讲真我也不知道为什么我的4000端口会被占用,我只是如常一样地使用Hexo而已。

问题

hexo s浏览博客时,提示4000端口问题。代码提示如下:

$ hexo server
FATAL Port 4000 has been used. Try other port instead.
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/do
Error: listen EADDRINUSE 0.0.0.0:4000
    at Object.exports._errnoException (util.js:1026:11)
    at exports._exceptionWithHostPort (util.js:1049:20)
    at Server._listen2 (net.js:1257:14)
    at listen (net.js:1293:10)
    at net.js:1403:9
    at _combinedTickCallback (internal/process/next_tick.js:77:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
FATAL listen EADDRINUSE 0.0.0.0:4000
Error: listen EADDRINUSE 0.0.0.0:4000
    at Object.exports._errnoException (util.js:1026:11)
    at exports._exceptionWithHostPort (util.js:1049:20)
    at Server._listen2 (net.js:1257:14)
    at listen (net.js:1293:10)
    at net.js:1403:9
    at _combinedTickCallback (internal/process/next_tick.js:77:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

解决

可以在站点下的文件_config.yml内加上如下代码更改hexo-server运行时的端口号:

server:
  port: 40401
  compress: true
  header: true

其中40401可以换成想要运行的端口号。


 目录