Change the default port of local Hexo server
Preface
It’s a clear night , I set down in front of my laptop and ready to write something. When I ran hexo s
to check what my site looks like, I received a warning said FATAL Permission denied. You can't use port 4000.
So, it occurred to me to write a new passage to record how to solve this problem.
Temporary change the port
It’s a easy way to use command hexo s -p <port>
to temporarily change the port of your local server, the change of port will not be save when you close your terminal.
Most of the time, you can use the port larger than 5000 to solve this.
Modify the configuration file
Want to once and for all?
Yes, you can modify the configuration file to change the default port of your local Hexo server, now let me show you how to do this.
You can see a index.js
file in path node_modules\hexo-server
, then you can see the port .
1 | hexo.config.server = Object.assign({ |
And don’t forget to save after editing.
Now, run hexo s
,you can see your local Hexo server is running on a new port.