grunt-browser-sync: Other device can not connect to computer's IP
(I couldn’t find another similar issue so I opened a new one.)
I’ve been using grunt-browser-sync for a while and so far it’s great!
But I have a problem when I try to use it with the watchtask and server options. Somehow I remember that the first time it worked, but now it stopped working.
On my computer I can go to both localhost:3002 and 192.168.0.108:3002 and on both browser-sync works perfectly (refresh, injection).
But when I try to visit 192.168.0.108:3002 on my phone (on the same wifi network) it keeps saying it can’t connect to the IP (“Google Chrome could not connect to 192.168.0.108:3002.”) and it displays the standard search bar.
Here’s the Grunt file I use (I only included the watch and browsersync tasks here):
module.exports = function(grunt) {
grunt.initConfig({
watch: {
sass: {
files: [
'sass/*.sass',
'sass/*.scss'
],
tasks: ['sass:dist','autoprefixer']
},
style: {
files: [
'sass/*.sass',
'sass/*.scss'
],
tasks: ['sass:style']
},
js: {
files: ['jsraw/**/*.js'],
tasks: ['uglify']
},
content: {
files: [
'*.htm',
'*.html',
'_layouts/*.htm',
'_posts/*.htm',
'_posts/*.md',
'_includes/*.htm',
'css/*.css',
'js/**/*.js'
],
tasks: ['jekyll']
}
},
browserSync: {
files: {
src: ['dist/css/*.css', 'dist/**/*.html','dist/js/*.js']
},
options: {
browser: 'google chrome',
watchTask: true,
debugInfo: true,
server: {
baseDir: 'dist/',
index: 'index.html'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-browser-sync');
grunt.registerTask('build', ['sass:dist','uglify','jekyll']);
grunt.registerTask('default', ['build','browserSync','watch']);
grunt.registerTask('style', ['build','browserSync','watch:style']);
I’m not sure what’s going wrong here… any tips for troubleshooting this? I’m on Linux (Ubuntu 14.04) 64bit, node v0.11.14-pre, grunt-cli v0.1.13, grunt v0.4.5, browser-sync v0.9.1.
Many thanks!
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 16 (8 by maintainers)
I know this is an old topic but I just ran into the same issue trying to connect to the server on my phone. In my case the problem was that while using Virtualbox, it had created multiple ethernet adapters and browser-sync was defaulting to the first adapter rather than my WIFI adapter (so a different address). You can manually specify the host using the
hostoption, but disabling the unused VM adapters resolved having to specify that.(if you’re on Windows 10, you can see a list of adapters at
Control Panel\Network and Internet\Network Connections).I had everything working here, except for one thing:
–tunnel Use a public URL
works perfectly now, I have 4 devices on sync