I just solved the problem. The problem was Express 4.x , now treats app.listen() as an asynchronous operation, so listener.address() will only return data inside of app.listen()'s callback. If I declare port statically,Code going well but it is also not good usage because it still static. Have an any idea to make it dynamic?