解决运行nodejs代码Error: listen EADDRINUSE

at the first,

record this:

root@xxx:~/hexo# hexo server

[error] Error: listen EADDRINUSE

Error: listen EADDRINUSE

    at errnoException (net.js:901:11)

    at Server._listen2 (net.js:1039:14)

    at listen (net.js:1061:10)

    at Server.listen (net.js:1135:5)

    at Function.app.listen (/root/.nvm/v0.10.25/lib/node_modules/hexo/node_modules/express/lib/application.js:533:24)

    at /root/.nvm/v0.10.25/lib/node_modules/hexo/lib/plugins/console/server.js:86:9

    at /root/.nvm/v0.10.25/lib/node_modules/hexo/lib/post/load.js:67:7

    at /root/.nvm/v0.10.25/lib/node_modules/hexo/node_modules/async/lib/async.js:116:25

    at /root/.nvm/v0.10.25/lib/node_modules/hexo/node_modules/async/lib/async.js:24:16

    at exports.post (/root/.nvm/v0.10.25/lib/node_modules/hexo/lib/plugins/generator/asset.js:50:3)

because i modify the hexo default port 4000 to 80 with config file _config.yml

port 80 is used other application,

so

find the process and kill it

the command:

root@xxxxx:~/hexo# fuser -n tcp 80

80/tcp:                705   715   716   717   718

root@xxxxx:~/hexo# kill 705

then generate and start hexo

root@xxxxx:~/hexo# hexo generate

[info] Files loaded in 0.217s

[create] Public: archives/index.html

[create] Public: archives/2014/02/index.html

[create] Public: index.html

[create] Public: archives/2014/index.html

[create] Public: 2014/02/11/hi/index.html

[create] Public: 2014/02/11/hello-world/index.html

[info] 6 files generated in 0.344s

root@xxxxx:~/hexo# hexo server

[info] Hexo is running at localhost:80/. Press Ctrl+C to stop.

 

OK!

你可能感兴趣的:(nodejs)