远程获取版本2.2346.52失败及WhatsApp网页访问异常求助
解决WhatsApp-Web.js机器人的网络连接错误问题
错误现象
- 从远程获取版本2.2346.52失败,报错:
FetchError:请求https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html失败,原因是getaddrinfo ENOTFOUND raw.githubusercontent.com - 访问
https://web.whatsapp.com/时出现net::ERR_INTERNET_DISCONNECTED错误 - 最终应用崩溃,nodemon提示等待文件变更后重启
排查与修复步骤
1. 确认本地网络状态
- 先测试普通网站访问,确认网络未断开
- 执行ping命令验证域名解析:
若ping不通,说明域名解析异常,可切换公共DNS(如8.8.8.8、114.114.114.114)ping raw.githubusercontent.com ping web.whatsapp.com
2. 修复raw.githubusercontent.com访问问题
- 若DNS解析失败,手动修改hosts文件添加对应IP(先通过工具查询该域名最新有效IP):
- Windows:编辑
C:\Windows\System32\drivers\etc\hosts,添加一行:185.199.108.133 raw.githubusercontent.com - Linux/macOS:编辑
/etc/hosts,添加上述内容
- Windows:编辑
- 刷新DNS缓存:
- Windows:
ipconfig /flushdns - Linux:
sudo systemctl restart nscd(不同发行版命令可能有差异) - macOS:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
- Windows:
3. 验证WhatsApp Web可访问性
- 用浏览器直接打开
https://web.whatsapp.com/,确认页面能正常加载 - 若浏览器也无法访问,检查防火墙、代理或VPN是否拦截,暂时关闭相关工具重试
4. 固定WhatsApp版本(可选)
- 若远程版本获取持续失败,初始化客户端时指定本地版本文件:
可从能正常访问的设备手动下载对应版本文件,传到项目目录中const { Client } = require('whatsapp-web.js'); const client = new Client({ webVersionCache: { type: 'local', path: './wa-version.html' // 将下载好的版本HTML文件放在项目目录 } });
5. 重启项目
- 网络修复完成后,重启nodemon服务:
nodemon your-bot-file.js
内容的提问来源于stack exchange,提问作者Godwin Tobi
相关产品推荐
相关产品推荐

