Why can't I connect to a connect-served site over web sharing?

I'm using grunt, connect, and livereload to serve up a test page (it's a single flat HTML page) during development, and I want to test the site on my phone. Normally I do this using web sharing—by navigating to the site using my Mac's local URL (my-imac.local).

When I serve the page using Python's SimpleHTTPServer, this works fine. When I use grunt/connect, it's inaccessible there (though it's still accessible at localhost). How do I get connect configured to respond to these requests?

My gruntfile, for reference:

var path = require('path');
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;

var folderMount = function folderMount(connect, point) {
  return connect.static(path.resolve(point));
};

module.exports = function(grunt) {
  function registerRobustTasks(name, tasks) {
    grunt.registerTask(name, function() {
      // so we don't have stupid issues with grunt crashing
      // every time a test fails...
      grunt.option('force', true);
      grunt.task.run(tasks);
    });
  }

  grunt.initConfig({
    pkg : grunt.file.readJSON('package.json'),
    livereload : {
      port : 48341
    },
    connect : {
      livereload : {
        options : {
          port : 48342,
          middleware : function(connect, options) {
            return [lrSnippet, folderMount(connect, '.')];
          }
        }
      }
    },
    regarde : {
      html : {
        files : ['*.html'],
        tasks : ['livereload']
      }
    }
  });

  grunt.loadNpmTasks('grunt-regarde');
  grunt.loadNpmTasks('grunt-contrib-livereload');
  grunt.loadNpmTasks('grunt-contrib-connect');

  registerRobustTasks('default', ['livereload-start', 'connect', 'regarde']);
};

Turns out it was simple: I needed a hostname : '*' option on the connect server.

The simplest way to do this is to be on the same LAN as your computer with your mobile device, then to test on your phone, use the ip address of the computer and the port you chose to have your server listen on. For example http://ipaddress:port.

To verify grunt is running the server, you can use the lsof program from your shell.

$ lsof -i :port will return a programs on your computer that are bound to the specified port.

Likewise, if you drop the port number you can see a list of open files (unix treats everything like a file), you can find some interesting stuff too sometimes.

$ lsof -i