How to set up subdomain in Node.js (Express)?


I went to the domain registry and add the A record to with IP address, and and with the same IP Address.

Then in node, I have this:

server.use(express.vhost('', restApp)).
use(express.vhost('', webApp)).
use(express.vhost('', webApp)).
use(express.vhost('', webApp));

But I can only see the page from and, not nor

What else do I need to set up?

do I need to change the server (ubuntu) host entry as well? but I have done it in this way already:  localhost rest.localhost

what else do I need to do?

============== After almost 6 hours, I finally get working. it is the DNS that takes very long time to propagate…

but now, another question. do I have to set up each subdomain or sub-subdomain in DNS?

I tried this for DNS A record setting: “”

and in node, I add express.vhost(‘’);

but it doesn’t work. do I need to set in the DNS?

Problem courtesy of: murvinlai


I got it working now. use * for the A record, and then I can use the node to make the subdomain. :)

Solution courtesy of: murvinlai

View additional discussion.