why node js socket not working when change port to https?

不羁的心 提交于 2020-01-25 07:59:24

问题


Normally in app.js i use this code on port 3000 it's work good (on my-domain.com:3000).

.

http.listen(3000, function(){
    console.log('start server on port :3000');
});

then i want to use on https, so i change app.js to

http.listen(443, function(){
    console.log('start server on port :443');
});

When run node app.js , it's show error

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::443
    at Object.exports._errnoException (util.js:1012:11)
    at exports._exceptionWithHostPort (util.js:1035:20)
    at Server._listen2 (net.js:1252:14)
    at listen (net.js:1288:10)
    at Server.listen (net.js:1384:5)
    at Object.<anonymous> (/home/admin/web/my-domain.com/public_html/app.js:28:6)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)

Normally i have to access to my-domain.com:3000 for user chat. So i want to know how can i access to https://www.my-domain.com for user chat ?


回答1:


You have the following error message:

Error: listen EADDRINUSE :::443
[...]

This message means that the port 443 is currently in use by some process.

You can check which process is actually using the said port by executing one of the many tools for network checking (such as netstat for Windows, lsof or netstat on Linux).

Refer to the manual for those tools to achieve the correct result, based upon your operating system.



来源:https://stackoverflow.com/questions/50134724/why-node-js-socket-not-working-when-change-port-to-https

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!