https hapijs server not working on port 80 (ERR_CONNECTION_REFUSED)

1.3k views Asked by At

I am developing a website through HapiJS and I'm configuring SSL. I have already created certificate and private key, and configure the TLS for Hapi server.

The problem is this, the server is started successfully on port 80 (without giving any error) but when I go to "call" the site by browser that does not respond and as a result I: "The web page is not available (ERR_CONNECTION_REFUSED)" If I create (I start) the server on another port, such as port 8080, the site responds properly. For clarity I add the pieces of code that make up the hapi server:



     private server = new Hapi.Server({ debug: { request: ['error'] } });
     this.server.connection({
       port: '0.0.0.0',
       host: 80,
       tls: {
          key: fs.readFileSync(__dirname + "/user_domain_io_key.pem", 'utf8'),
          cert: fs.readFileSync(__dirname + "/user_domain_io_cert.pem", 'utf8')
       }
     });

     this.server.route({
      path: '/login',
      method: 'GET',
      handler: function(request, reply) {
         reply.view('login');
      }
     });

     this.server.start(function () {
      console.log('server running at: ' + that.server.info.uri);
     });

What I do not understand is why the site is not liable if the server start on port 80. Do you have any advice for me? Someone has already dealt with the problem? Thanks.

1

There are 1 answers

0
Jonathan Lake On

Don't you have the port and host parameters reversed?

Shouldn't it be

port: 80

host: '0.0.0.0'