title: How to test a node.js server from command line
body: <p>I am programming an iOS app that needs to use an web service to create an authentication token.  I have written a node.js server to create the token.</p>
  
  <p>I know that I could use curl to test this server locally from the command line but I can't seem to get it to work.</p>
  
  <p>here is a snippet of the server code </p>
  
  <pre><code>var app = express();
  ....
  
  app.post('/authenticate', function(req, res) {
     // create token
     ......
  
     res.json({
        identity_token: jws
     });
  });
  
  var port = process.env.PORT || 3000;
  app.listen(port, function(err) {
     if(err) throw err;        
     console.log('Express server running on localhost:%d', port);
  });
  </code></pre>
  
  <p>I have tried using the following curl command</p>
  
  <pre><code>curl -H "Content-Type: application/json" -X POST -d '{"user_id":"USER_ID","nonce":"NONCE"}' http://localhost/authenticate
  </code></pre>
  
  <p>The error I receive is "Failed to connect to localhost port 80: Connection refused"</p>
  
  <p>I would really appreciate any help or examples on how to test this server. </p>