you need to ensure that the port numbers that you start mongod with
(using --port or 27017 by default) match the host and port numbers you
try to connect with in your code. You also need to ensure that the
ports are opened on any firewall between mongod and the client.
You need to supply more information and configuration for us to help
further (as Nat suggested).
-Alvin