I've been following this(http://socket.io/get-started/chat/) tutorial on how to make a simple chat application using socket.io.
I tried to however use Express to create it and I was wondering why port 3000 is already in use? The code below will not work unless I change the port number.
/* Make the http server listen on port 3000. */
http.listen(3000, function(){
console.log('listening on *:3000');
});
Does express use the port to do other things like routing or something? Is there a simple way to find what is happening on that port?
I may also be doing something dodgy with my require things:
var express = require('express');
var app = require('express')();
var http = require('http').Server(app);
var router = express.Router();
var io = require('socket.io')(http);
Thanks.
You can stop process with ctrl+C in the terminal window.
3000 is a somewhat arbitrary port number chosen because it allows you to experiment with express without root access (elevated privilege). Ports 80 and 443 are the default HTTP and HTTPS ports but they require elevated privilege in most environments.
0.0 or 127.0. 0 and it chose the port 3000 you can configure it to other ports too. So, when you type http://localhost:3000 in the addressbar of the browser you can see the first page hosted from your app. You can make use of etc/hosts file to a local name just like http://localhost:3000 to http://localapp.me too.
I ran into this problem too and I solved it by this:
Do not use npm start
to start your web app
Use node app.js
instead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With