在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vscode開發(fā)node http/https模塊 connect ECONNR

vscode開發(fā)node http/https模塊 connect ECONNREFUSED 127.0.0.1 3300

問題描述

如題,vscode開發(fā)node http/https模塊 connect ECONNREFUSED 127.0.0.1 3300

問題出現(xiàn)的環(huán)境背景及自己嘗試過哪些方法

當(dāng)我把相關(guān)options的hostname設(shè)置成‘encrypted.google.com’,不會報錯
const options = {
  hostname: 'encrypted.google.com',
  port: 443,
  path: '/',
  method: 'GET'
};
但是設(shè)置成本地hostname:‘localhost’  port: '3300' 時會報錯
Error: connect ECONNREFUSED 127.0.0.1 3300

相關(guān)代碼

// 請把代碼文本粘貼到下方(請勿用圖片代替代碼)

const https = require('https');
const http = require('http');

const option = {
hostname: '127.0.0.1',
port: '3300',
path: '/',
method: 'GET',
header: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Content-Length': 20
}
};

let servers = https.request(option, (res) => {
console.log('狀態(tài)碼', res.statusCode);
console.log('請求頭', res.headers);

res.on('data', d => {
    process.stdout.write(d);
})
})

servers.on('error', err => {
console.log('Error', err);
});

servers.end();

clipboard.png

你期待的結(jié)果是什么?實際看到的錯誤信息又是什么?

解決報錯問題
回答
編輯回答
遺莣

應(yīng)該是端口占用吧

2017年6月2日 12:28