6

i should probably point out that i'm inexperienced user first, and my issue is that the 'hostname' property can't have any values assigned except for an empty string(''), '0.0.0.0' and 'localhost'. I getting: Fatal error: getaddrinfo ENOTFOUND. What am i doing wrong?

If get it right, i can change the adress that i'm usually typing in the address bar, so instead 'localhost' i could have typed 'example.com' or something like that.

As i mentioned above i've assigned it different values but only three of them have worked. so why this '*' isn't working.

Here is My Gruntfile.js:

module.exports = function( grunt ) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),   

        watch: {
            scripts: {
                files: ['*.js'],
                options: {
                    livereload: true
                }
            },
            markup: {
                files: ['*.html'],
                options: {
                    livereload: true
                }
            },
            stylesheets: {
                files: ['*.css'],
                options: {
                    livereload: true
                }
            }
        },
        connect: {
            server: {
                options: {
                    hostname: '*',
                    port: 2000, 
                    base: '.'
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-connect');

    grunt.registerTask('default', ['connect','watch']);

};

Working on Ubuntu 12.04 64bit

NodeJs 0.10.17

npm 1.3.8

GruntJs 0.4.1

grunt-contrib-connect 0.3.0

orustammanapov
  • 1,792
  • 5
  • 25
  • 44
  • 2
    It would help a lot if you write down what you are trying to do, and also the relevant parts of your Grunt config.js file so we can actually help you here – Gilad Peleg Aug 24 '13 at 20:53
  • fair enough:). i was playing with settings of the grunt-contrib-connect plugin and my intention was to check what the hostname property was for. If get it right, i can change the adress that i'm usually typing in the address bar, so instead 'localhost' i could have typed 'example.com' or something like that. As i mentioned above i've assigned it different values but only three of them have worked. so why this '*' isn't working – orustammanapov Aug 24 '13 at 21:06
  • Errr. just re-edit your post, insert with code formatting the relevant parts of your GruntJS file – Gilad Peleg Aug 24 '13 at 21:11

1 Answers1

11

It is because grunt is attempting to bind to that address as a Server. It is not possible to bind as a server to arbitrary IP addresses or domain names.

  • 0.0.0.0 means listen to on all IP addresses bound to this host
  • 127.0.0.1/localhost means bind to the local adapter
  • nnn.nnn.nnn.nnn binds to a particular IP address (it must resolve locally)
dc5
  • 12,341
  • 2
  • 35
  • 47
  • so it just takes existing addresses from the hosts file and binds the server to the address i pass?? – orustammanapov Aug 24 '13 at 21:46
  • Thanks for pointing in the right direction. I had to add the hostname specified in grunt config (conntect/options/hostname) to my hosts file and flush my dns cache – aron.lakatos Oct 21 '14 at 07:00