简体   繁体   中英

I have executed a node js server on cPanel, it is succefully executing but still my server is not accessible using public IP address of my server

I have executed a nodejs server on port 8080 on cPanel using SSH access. I have provided public IP address of my server as a host name for node js server. But still I m not able to access the server by entering the public IP address and port number in browser URL.

在此处输入图片说明

Code:

 'use strict';
  const Hapi = require('hapi');
  const server = Hapi.server({
  port: 8080,
  host: '1.1.1.1' //servers public IP adrress
  });
  server.route({
    method: 'GET',
    path: '/',
    handler: (request, h) => {
      return 'Hello, world!';
      }
    });

  const init = async () => {
    await server.start();
    console.log(`Server running at: ${server.info.uri}`);
  };
  process.on('unhandledRejection', (err) => {
    console.log(err);
    process.exit(1);
  });

init();

I have solved this problem.

The problem was the port on which I was trying to run this application was not open to outside accessors.

I contacted to support team of cloud server on which I have deployed my application, and then they have opened the port.

And after opening the port now it is accessible to outside accessors.

Thank you for your time and efforts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM