You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Axios配置代理失败,出现SSL版本错误,求问题排查方案

Axios代理配置失败排查与解决

多次尝试在Axios中配置代理但始终无法成功,以下是复现问题的示例代码:

const axios = require('axios');

// Make the GET request with Axios and the proxy agent
axios.get('https://ip.smartproxy.com', {
    proxy: {
        host: '185.122.168.215',
        port: 34991
        // no need to user and password cuz i already in the whitelist 
        // i tryied free proxy and its not work 
    }
})
.then(response => {
    console.log('Response:', response.data);
})
.catch(error => {
    console.error('Error:', error);
});

执行上述代码后出现以下错误:

cause: Error: write EPROTO B4370000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:355:

at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16) {
    errno: -4046,
    code: 'EPROTO',
    syscall: 'write'
  }
}

可能的原因及解决办法

  • 代理类型不匹配:请求HTTPS目标地址时,若代理是HTTP类型,需确保其支持CONNECT方法;如果是SOCKS5代理,Axios原生proxy配置不支持,需使用socks-proxy-agent库适配。
  • SSL协议版本不兼容:错误提示的wrong version number表明SSL握手时版本不匹配,可尝试指定TLS版本:
    const axios = require('axios');
    const https = require('https');
    
    axios.get('https://ip.smartproxy.com', {
        proxy: {
            host: '185.122.168.215',
            port: 34991
        },
        httpsAgent: new https.Agent({
            secureProtocol: 'TLSv1_2_method'
        })
    })
    .then(res => console.log('Response:', res.data))
    .catch(err => console.error('Error:', err));
    
  • 代理有效性验证:确认代理服务器正常运行、你的IP在白名单内、端口正确,可先用curl测试:
    curl -x http://185.122.168.215:34991 https://ip.smartproxy.com
    
  • Axios版本问题:旧版本Axios代理处理可能存在bug,更新到最新版本:
    npm update axios
    

内容的提问来源于stack exchange,提问作者Test 0oczi_ Uıu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 10:12:47