Reputation: 533
im new with node and a have a problem with express, my app only listen to localhost:PORT and i wanna to the app listen to localhost too, heres is my code,
**
var app = require('../app');
var debug = require('debug')('App');
var http = require('http');
var port = normalizePort(process.env.PORT || '8000');
app.set('port', port);
var server = http.createServer(app);
server.listen(port, 'localhost');
server.on('error', onError);
server.on('listening', onListening);
**
Upvotes: 2
Views: 3037
Reputation: 615
You cannot listen without a port, because that would not make any sense. Every TCP connection needs to happen over some port. What you are looking for is the default 80 port for http, or 443 for https. The browser uses these ports by default.
Depending on the configuration of your system, a user space program may not necessarily have access to these ports. So you may have to configure your system to grant your node application access.
Upvotes: 1