gRPC/REST TCP sockets cannot be bound to a specific host
@bharatjetti 已经在做这个了。
开始于 2026年3月24日。
评估
这个 Issue 还没有评估数据。
描述
Feature Request
Describe the problem the feature is intended to solve
The hostname 0.0.0.0 is hardcoded in the source code (with a comment that mistakenly claims that this results in listening on localhost):
I would like to be able to have the gRPC & REST APIs actually listen on localhost/127.0.0.1 so that the APIs are not exposed to the outside.
I'm aware of the option to create a UNIX socket instead using --grpc_socket_path, which I suppose I could proxy to a TCP socket that does listen on localhost. However, there's no such option for the REST API. The only option is to disable it completely by setting --rest_api_port=0.
Describe the solution
I would like there to be new command-line flags to set a hostname for the gRPC & REST APIs to listen on. The existing --port and --rest_api_port arguments could even be extended to accept a string like 127.0.0.1:8500.
Describe alternatives you've considered
The flag --grpc_socket_path is an alternative for the gRPC API, but there is no alternative for the REST API.
Additional context
I want to use this for network security purposes to not expose TensorFlow Serving more than it needs to be.
Temporary workaround
One way to temporarily solve this problem without having to fork TFS is to override the bind call using LD_PRELOAD, for example by using this snippet. You can then have TensorFlow Serving listen on localhost by running it like this:
BIND_ADDR="127.0.0.1" LD_PRELOAD=/bind_override/bind.so tensorflow_model_server --port=8500 --rest_api_port=8501 --model_name=model --model_base_path=/models/model
The log messages will continue to say that TFS is listening on 0.0.0.0, but netstat shows that it will be listening on localhost instead:
$ netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8500 0.0.0.0:* LISTEN 11/tensorflow_model
tcp 0 0 127.0.0.1:8501 0.0.0.0:* LISTEN 11/tensorflow_model
- 主要语言
- C++
- 星标
- 6.4k
- 派生
- 2.2k
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
tensorflow/serving 的其他 Issue
-
gpg key expired 未关闭bug
难度 4/5 3-5 天 新手友好度 38/100
tensorflow/serving#4150 · 1 条评论 · 已指派 1 人 ·
-
stat:awaiting tensorflower type:support
tensorflow/serving#4139 · 1 条评论 · 已指派 1 人 ·
-
stat:contributions welcome type:bug
tensorflow/serving#4116 · 1 条评论 · 已指派 1 人 ·
-
stat:contributions welcome type:build/install
tensorflow/serving#4108 · 8 条评论 · 已指派 1 人 ·
-
stat:contributions welcome type:docs
tensorflow/serving#2255 · 2 条评论 · 已指派 1 人 ·
查看 tensorflow/serving 的全部 Issue
相似的 Issue
-
bug build
难度 1/5 1 小时以内 新手友好度 91/100
facebookincubator/velox#19194 ·
-
JIT-compiled number -> Decimal conversion silently overflows instead of raising DECIMAL_OVERFLOW 未关闭fuzz
难度 2/5 1-3 小时 新手友好度 82/100
ClickHouse/ClickHouse#122114 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
-
module/agent platform/macos type/bug/regression
难度 2/5 1-3 小时 新手友好度 88/100
-
enhancement PyCDE
难度 2/5 1-3 小时 新手友好度 78/100