0

Hot can i use node js socket io on port 443 as same as https ?

When i use this command line ss -nltp|grep :443 for check application that currnetly working on port 443, i get this

LISTEN     0      128    xxx.xx.x.xxx:443                      *:*                   users:(("nginx",pid=27314,fd=10),("nginx",pid=27313,fd=10),("nginx",pid=27312,fd=10))

So in app.js i change to this

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

for use node js socket io on https port

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)

I want to know how can i use multiple application on the same port, in this case on poer 443 ?

Normally i have to access to my-domain.com:3000 for use node js socket io. So i want to know how can i access to https://www.my-domain.com for use node js socket io ?

reswe teryuio
  • 117
  • 1
  • 1
  • 8
  • Well, it appears that there's an nginx proxy on 443. Are you using that? Or is that from something else? If it's yours, then you would configure it to route https on port 443 to your server on some other http port and make your server not be directly accessible to the outside world - using nginx as your https front-end that proxies to your regular http server. This is sometimes how https is implemented in hosting situtations. – jfriend00 May 03 '18 at 03:09
  • Also, it's unclear how this question is any different than your previous one from earlier in the day: [Why node js is not working when change port to https](https://stackoverflow.com/questions/50134724/why-node-js-socket-not-working-when-change-port-to-https). – jfriend00 May 03 '18 at 03:15

0 Answers0