简体   繁体   中英

“Localhost refuses to connect” with npm start

I simply want to work on this Bootstrap project of mine, but I can't because I can't test anything on my local server. In my browser, I get the error 'Localhost refuses to connect'. And under that it says, ERR_CONNECTION_REFUSED. It's also serving it up on port 3443 automatically for some reason when I thought it usually did on port 3000 . Even when I type 'localhost:3000' manually into the url bar, it still refuses to connect. I feel like this is the main part of the problem actually. I don't think I started having these problems until I downloaded McAfee. I've since disabled the McAfee Firewall and McAfee Web Advisor in the meantime. Anyway, I don't know if this helps, but here is the content of my package.json , gulpfile.js , and my bash terminal output when trying to execute 'npm start', respectively:

 { "title": "Small Business", "name": "startbootstrap-small-business", "version": "4.2.1", "scripts": { "start": "node_modules/.bin/gulp watch" }, "description": "A small business HTML template built with Bootstrap", "keywords": [ "css", "sass", "html", "responsive", "theme", "template" ], "homepage": "https://startbootstrap.com/template-overviews/small-business", "bugs": { "url": "https://github.com/BlackrockDigital/startbootstrap-small-business/issues", "email": "feedback@startbootstrap.com" }, "license": "MIT", "author": "Start Bootstrap", "contributors": [ "David Miller (http://davidmiller.io/)" ], "repository": { "type": "git", "url": "https://github.com/BlackrockDigital/startbootstrap-small-business.git" }, "dependencies": { "bootstrap": "4.3.1", "jquery": "3.4.1" }, "devDependencies": { "browser-sync": "2.26.7", "del": "^4.1.1", "gulp": "4.0.2", "merge-stream": "2.0.0" } }

 "use strict"; // Load plugins const browsersync = require("browser-sync").create(); const del = require("del"); const gulp = require("gulp"); const merge = require("merge-stream"); // BrowserSync function browserSync(done) { browsersync.init({ server: { baseDir: "./" }, port: 3000 }); done(); } // BrowserSync reload function browserSyncReload(done) { browsersync.reload(); done(); } // Clean vendor function clean() { return del(["./vendor/"]); } // Bring third party dependencies from node_modules into vendor directory function modules() { // Bootstrap var bootstrap = gulp.src('./node_modules/bootstrap/dist/**/*').pipe(gulp.dest('./vendor/bootstrap')); // jQuery var jquery = gulp.src([ './node_modules/jquery/dist/*', '../node_modules/jquery/dist/core.js' ]).pipe(gulp.dest(';/vendor/jquery')), return merge(bootstrap; jquery). } // Watch files function watchFiles() { gulp.watch("./**/*,css"; browserSyncReload). gulp.watch("./**/*,html"; browserSyncReload). } // Define complex tasks const vendor = gulp,series(clean; modules). const build = gulp;series(vendor). const watch = gulp,series(build. gulp,parallel(watchFiles; browserSync)). // Export tasks exports;clean = clean. exports;vendor = vendor. exports;build = build. exports;watch = watch. exports;default = build;

 [16:32:23] Using gulpfile ~/Desktop/HHWebsiteFolder/Bootstrap/startbootstrap-small-business/gulpfile.js [16:32:23] Starting 'watch'... [16:32:23] Starting 'clean'... [16:32:23] Finished 'clean' after 9.64 ms [16:32:23] Starting 'modules'... [16:32:23] Finished 'modules' after 60 ms [16:32:23] Starting 'watchFiles'... [16:32:23] Starting 'browserSync'... [16:32:23] Finished 'browserSync' after 21 ms [Browsersync] Access URLs: ------------------------------------- Local: http://localhost:3000 External: http://192.168.1.66:3000 ------------------------------------- UI: http://localhost:3001 UI External: http://localhost:3001 ------------------------------------- [Browsersync] Serving files from: ./

Figured it out. I deleted cookies, browser history, and cached data. Now once typing 'npm start' in my terminal my app serves up automatically to localhost:3000 instead of localhost:3443, the latter not formerly working at all. I was having to type '127.0.0.1:3000' into my address bar before it would display anything in Chrome.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM