首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“连接拒绝”角4本地主机开发

“连接拒绝”角4本地主机开发
EN

Stack Overflow用户
提问于 2018-07-26 06:00:13
回答 4查看 23.8K关注 0票数 5

我得到了“连接拒绝”页面,而运行角4应用程序本地。

URL为http://localhost:4200/

使用ng serve --open命令运行该应用程序。

更新1: angular.json

对于一些来源,我发现角cli文件现在被更改为angular.json

下面是agnular.json的详细信息

代码语言:javascript
复制
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
  "angular-forms": {
    "root": "",
    "sourceRoot": "src",
    "projectType": "application",
    "architect": {
      "build": {
        "builder": "@angular-devkit/build-angular:browser",
        "options": {
          "outputPath": "dist",
          "index": "src/index.html",
          "main": "src/main.ts",
          "tsConfig": "src/tsconfig.app.json",
          "polyfills": "src/polyfills.ts",
          "assets": [
            "src/assets",
            "src/favicon.ico"
          ],
          "styles": [
            "src/styles.css"
          ],
          "scripts": []
        },
        "configurations": {
          "production": {
            "optimization": true,
            "outputHashing": "all",
            "sourceMap": false,
            "extractCss": true,
            "namedChunks": false,
            "aot": true,
            "extractLicenses": true,
            "vendorChunk": false,
            "buildOptimizer": true,
            "fileReplacements": [
              {
                "replace": "src/environments/environment.ts",
                "with": "src/environments/environment.prod.ts"
              }
          ]
        }
      }
    },
    "serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "options": {
        "browserTarget": "angular-forms:build"
      },
      "configurations": {
        "production": {
          "browserTarget": "angular-forms:build:production"
        }
      }
    },
    "extract-i18n": {
      "builder": "@angular-devkit/build-angular:extract-i18n",
      "options": {
        "browserTarget": "angular-forms:build"
      }
    },
    "test": {
      "builder": "@angular-devkit/build-angular:karma",
      "options": {
        "main": "src/test.ts",
        "karmaConfig": "./karma.conf.js",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "src/tsconfig.spec.json",
        "scripts": [],
        "styles": [
          "src/styles.css"
        ],
        "assets": [
          "src/assets",
          "src/favicon.ico"
        ]
      }
    },
    "lint": {
      "builder": "@angular-devkit/build-angular:tslint",
      "options": {
        "tsConfig": [
          "src/tsconfig.app.json",
          "src/tsconfig.spec.json"
        ],
        "exclude": [
          "**/node_modules/**"
        ]
      }
    }
  }
},
"angular-forms-e2e": {
  "root": "",
  "sourceRoot": "",
  "projectType": "application",
  "architect": {
    "e2e": {
      "builder": "@angular-devkit/build-angular:protractor",
      "options": {
        "protractorConfig": "./protractor.conf.js",
        "devServerTarget": "angular-forms:serve"
      }
    },
    "lint": {
      "builder": "@angular-devkit/build-angular:tslint",
      "options": {
        "tsConfig": [
          "e2e/tsconfig.e2e.json"
        ],
        "exclude": [
          "**/node_modules/**"
        ]
      }
    }
  }
}
},
"defaultProject": "angular-forms",
"schematics": {
"@schematics/angular:component": {
  "prefix": "app",
  "styleext": "css"
},
"@schematics/angular:directive": {
  "prefix": "app"
}
}
}

如果需要更多的细节,请告诉我

屏幕截图是附加的更多细节。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2018-07-30 08:36:38

我已经找到了解决这个问题的办法,而且很简单。正如@Devid问我关于公司代理的问题一样,我已经开始朝这个方向寻找解决方案。最后,我发现我的LAN代理设置中有一些小错误。

在配置代理服务器时,我忘记启用选项“本地地址的旁路代理服务器”,这将导致上述错误。

下面是屏幕截图,以了解更多细节。

票数 1
EN

Stack Overflow用户

发布于 2019-07-12 11:44:32

转到命令行并运行ng serve --port 4200

希望这能有所帮助。

票数 3
EN

Stack Overflow用户

发布于 2018-07-26 06:04:59

而不是像这样使用localhost来访问你的应用程序,

在命令行中,键入=> ipconfig并复制它返回的ip地址,

如果IP地址为192.168.0.10,则可以访问您的应用程序(在发出ng server后),

代码语言:javascript
复制
http://192.168.0.10:4200

希望这能有所帮助!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51531931

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档