执行bazel version命令遇报错:120秒后无法连接服务器(1657),求故障原因
Bazel本地服务器连接超时(FATAL: couldn't connect to server after 120 seconds)的可能原因
此前执行bazel version可正常运行,如今突然出现如下报错:
Bazelisk version: v1.7.5 Starting local Bazel server and connecting to it... ... still trying to connect to local Bazel server after 10 seconds ... ... still trying to connect to local Bazel server after 20 seconds ... ... still trying to connect to local Bazel server after 30 seconds ... ... still trying to connect to local Bazel server after 40 seconds ... ... still trying to connect to local Bazel server after 50 seconds ... ... still trying to connect to local Bazel server after 60 seconds ... ... still trying to connect to local Bazel server after 70 seconds ... ... still trying to connect to local Bazel server after 80 seconds ... ... still trying to connect to local Bazel server after 90 seconds ... ... still trying to connect to local Bazel server after 100 seconds ... ... still trying to connect to local Bazel server after 110 seconds ... FATAL: couldn't connect to server (1657) after 120 seconds.
可能的故障原因:
- 残留异常进程:之前的Bazel服务器进程未正常退出,占用端口或系统资源,导致新进程无法启动或建立连接。检查并终止系统中残留的
bazel相关进程后重试。 - 系统资源耗尽:内存、CPU被其他进程占用过多,Bazel服务器无法正常启动或响应请求。查看系统资源使用情况,释放资源后再尝试。
- 安全软件拦截:防火墙或本地安全软件新增规则,拦截了Bazel服务器的端口通信。检查防火墙设置,允许Bazel相关进程的网络访问权限。
- 版本兼容性问题:系统更新、环境变量变化后,Bazelisk拉取的Bazel版本与当前环境不兼容。可指定明确的Bazel版本(如
bazelisk --version=<具体版本> version)尝试,或清理Bazelisk缓存目录。 - 缓存目录损坏:Bazel默认缓存目录(
~/.cache/bazel)损坏,影响服务器启动。清理该缓存目录后重新运行命令。 - 端口被占用:Bazel服务器默认使用的端口被其他程序占用。可通过
bazel build --host_jvm_args=-Dbazel.ServerPort=<自定义端口>指定新端口尝试。
内容的提问来源于stack exchange,提问作者EngMe
相关产品推荐
相关产品推荐

