Sunday, 2 April 2017

expressjs code listing on tcp6 port rather than ipv4

Env is :- ubuntu 14.04

My node version is :-

 node --version
 v6.9.4

Here is my code.

// dependencies :-
 var express = require ('express');
var mongoose = require ('mongoose');
var bodyParser = require ('body-parser');

var app = express();
app.use(bodyParser.urlencoded({extended: true}) );
app.use (bodyParser.json());


// routes :
api=require('./routes/api');
app.post('/register',api.register);
app.post('/authenticateUser',api.authenticateUser)
app.post('/update',api.updateUser);
//start server 

app.listen (8070);

console.log('Server Started & listing at 8070 ');

It was listing on both IPv4 & IPV6 till 2 days back my code was working fine.

But now all the way in between it seems like express code is only listing on tcp6 ( IPv6 ). Googled it but everbody faced this issue in 0.x.x.

Here is output of terminal

xxx@ubuntu:~$ netstat -a | grep 8070
 tcp6       0      0 [::]:8070               [::]:*                  LISTEN 

My Code seems to be perfect.Any ideas or any clue whats happening to system ????

Output of interfaces is :-

eth0      Link encap:Ethernet  HWaddr 00:0c:29:d1:ce:56  
          inet addr:192.168.0.13  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fed1:ce56/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:26221 errors:0 dropped:0 overruns:0 frame:0
      TX packets:10916 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:27443150 (27.4 MB)  TX bytes:1365295 (1.3 MB)

lo        Link encap:Local Loopback  
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:65536  Metric:1
      RX packets:9366 errors:0 dropped:0 overruns:0 frame:0
      TX packets:9366 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:5748317 (5.7 MB)  TX bytes:5748317 (5.7 MB)



via Inder R Singh

No comments:

Post a Comment