render-env-vars
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEnvironment Variables on Render
Render 上的环境变量
Render exposes configuration to services as environment variables. Values are always strings at the platform layer—applications must parse numbers, booleans, and structured data explicitly.
There are three primary ways to set variables:
- Render Dashboard — per-service UI, bulk import from , save/redeploy options
.env - Blueprint — (and related keys) in
envVarsrender.yaml - MCP / API — e.g. on a service
update_environment_variables
Deep wiring patterns, full platform variable tables, and language-specific notes live under .
references/Render 以环境变量的形式向服务公开配置。在平台层,值始终是字符串——应用程序必须显式解析数字、布尔值和结构化数据。
设置变量主要有三种方式:
- Render 仪表板 — 每个服务的专属UI,支持从批量导入,提供保存/重新部署选项
.env - Blueprint — 中的
render.yaml(及相关键)envVars - MCP / API — 例如对服务执行操作
update_environment_variables
深度关联模式、完整平台变量表和语言相关说明可查看目录下的内容。
references/When to Use This Skill
何时使用此技能
Use this skill when users want to:
- Add, change, or remove environment variables or secrets
- Understand Dashboard vs Blueprint vs API/MCP flows
- Use environment groups for shared configuration
- Wire ,
fromDatabase,fromService,fromGroup, orsync: falsein BlueprintsgenerateValue - Debug missing vars, secret files, precedence, or platform-injected names
For full Blueprint authoring, pair with render-blueprints. For first-time deploys, render-deploy. For web service behavior and ports, render-web-services.
当用户需要以下操作时,可使用此技能:
- 添加、修改或删除环境变量或密钥
- 了解仪表板、Blueprint与API/MCP的操作流程差异
- 使用环境组实现共享配置
- 在Blueprint中配置、
fromDatabase、fromService、fromGroup或sync: falsegenerateValue - 调试缺失的变量、密钥文件、优先级问题或平台注入的变量名称
如需完整的Blueprint编写指导,请搭配render-blueprints技能。首次部署请使用render-deploy技能。Web服务行为与端口相关问题请使用render-web-services技能。
Setting Variables
设置变量
Dashboard
仪表板
- Add variables individually (name + value) or in bulk by pasting/uploading a -style file.
.env - Save options typically include:
- Save and rebuild & deploy — picks up build-time changes
- Deploy only — runtime change without a full rebuild (when applicable)
- Save only — persist without triggering a deploy
Use Dashboard edits when iterating quickly or when the repo should not carry certain values.
- 可以单独添加变量(名称+值),也可以通过粘贴/上传格式的文件批量添加。
.env - 保存选项通常包括:
- 保存并重新构建与部署 — 应用构建阶段的变更
- 仅部署 — 仅应用运行时变更,无需完整重建(适用时)
- 仅保存 — 保存变更但不触发部署
快速迭代或仓库不应包含特定值时,适合使用仪表板编辑。
Blueprint (render.yaml
)
render.yamlBlueprint(render.yaml
)
render.yamlDeclare on each service. Values can be literals, generated secrets, sync-disabled prompts, or references to databases, other services, or env groups. See Blueprint Wiring below and for exhaustive patterns and YAML.
envVarsreferences/wiring-reference.md在每个服务中声明。值可以是字面量、生成的密钥、禁用同步的提示,或是对数据库、其他服务或环境组的引用。详细模式与YAML示例请查看下方的Blueprint关联以及。
envVarsreferences/wiring-reference.mdMCP / API
MCP / API
Automation tools can set variables on existing services (e.g. ). Useful for CI, rotation, or keeping Dashboard state in sync with external secret stores—without committing secrets to Git.
update_environment_variables自动化工具可对现有服务设置变量(例如)。适用于CI流程、密钥轮换,或保持仪表板状态与外部密钥存储同步——无需将密钥提交到Git。
update_environment_variablesSecret Management
密钥管理
- — Render prompts in the Dashboard for the value only on initial Blueprint setup when the resource is first created. On Blueprint updates,
sync: falseis ignored (values are not re-prompted from the file alone). These vars are excluded from preview environments and are invalid inside environment groups.sync: false - — Render generates a base64-encoded 256-bit random value at provision time. Use for passwords, signing keys, or tokens that do not need human-chosen values.
generateValue: true - Never commit real secrets in as plain
render.yamlentries. Prefer Dashboard, secret manager integration,value:, orgenerateValuewith Dashboard entry.sync: false
- — 仅在首次创建资源、初始设置Blueprint时,Render会在仪表盘中提示输入值。在Blueprint更新时,
sync: false会被忽略(不会仅通过文件重新提示输入值)。这些变量不会出现在预览环境中,且在环境组内无效。sync: false - — Render会在配置阶段生成一个base64编码的256位随机值。适用于密码、签名密钥或无需人工指定值的令牌。
generateValue: true - 切勿在中以明文
render.yaml条目提交真实密钥。优先使用仪表板、密钥管理器集成、value:,或结合generateValue在仪表板中输入值。sync: false
Secret files
密钥文件
- Store sensitive file content as secret files (not inline env strings). They appear as plaintext files under .
/etc/secrets/<filename> - Combined limit: 1 MB total secret file payload per service or per linked env group (as applicable to your setup).
- Docker: secret files are available under on the running instance.
/etc/secrets/
- 将敏感文件内容存储为密钥文件(而非内联环境字符串)。它们会以明文文件的形式出现在****路径下。
/etc/secrets/<filename> - 总限制:每个服务或每个关联的环境组的密钥文件总 payload 为1 MB(取决于你的配置)。
- Docker:密钥文件在运行实例中位于****路径下。
/etc/secrets/
Environment Groups
环境组
Environment groups are named collections of variables linked to multiple services.
- Precedence: Service-level variables override variables from linked groups with the same name.
- Multiple groups on one service: the group that was most recently created wins for overlapping keys. This ordering is not documented as stable—avoid relying on it; use distinct names or consolidate groups.
- Groups can be scoped to a project environment so staging and production differ without duplicating every service definition.
环境组是关联到多个服务的命名变量集合。
- 优先级:服务级变量会覆盖同名的组变量。
- 单个服务关联多个组:对于重复的键,最近创建的组生效。此排序未被记录为稳定状态——避免依赖该规则;请使用不同的名称或合并组。
- 组可以限定在项目环境中,这样 staging 和 production 环境无需重复每个服务定义即可实现差异配置。
Blueprint Wiring (Summary)
Blueprint关联(摘要)
Full syntax, examples, and edge cases: . Authoritative Blueprint docs: render-blueprints skill.
references/wiring-reference.md| Mechanism | Role |
|---|---|
| Hardcoded string (non-secret config only) |
| Platform-generated secret |
| Dashboard prompt on initial create only |
| Inject DB fields ( |
| Key Value: |
| Link all vars from a named group |
完整语法、示例与边缘情况请查看:。权威Blueprint文档请参考render-blueprints技能。
references/wiring-reference.md| 机制 | 作用 |
|---|---|
| 硬编码字符串(仅适用于非机密配置) |
| 平台生成的密钥 |
| 仅在初始创建时触发仪表板提示 |
| 注入数据库字段( |
| 键值对: |
| 关联指定组的所有变量 |
Platform-Injected Variables
平台注入变量
Render sets read-only variables your app can read at runtime (and some at build). A concise list:
| Variable | Typical meaning |
|---|---|
| |
| Service kind (e.g. web, worker) |
| Service identifier |
| Human-readable service name |
| Current instance |
| Public URL (when applicable) |
| Public hostname |
| Service discovery hostname (private network) |
| Deployed commit SHA |
| Branch for this deploy |
| HTTP port to bind (default |
| Preview deploy indicator |
| vCPU count for the instance |
| Suggested worker/process count hint |
Build vs runtime availability, language version env vars, and WEB_CONCURRENCY defaults: .
references/platform-variables.mdRender会设置只读变量,你的应用可在运行时(部分在构建时)读取。简要列表如下:
| 变量 | 典型含义 |
|---|---|
| 在Render上运行时为 |
| 服务类型(例如web、worker) |
| 服务标识符 |
| 人类可读的服务名称 |
| 当前实例 |
| 公开URL(适用时) |
| 公开主机名 |
| 服务发现主机名(私有网络) |
| 已部署的提交SHA |
| 本次部署的分支 |
| HTTP绑定端口(默认 |
| 预览部署标识 |
| 实例的vCPU数量 |
| 建议的工作进程/进程数量提示 |
构建时与运行时的可用性、语言版本环境变量以及WEB_CONCURRENCY默认值请查看。
references/platform-variables.mdRuntime-Specific Defaults
运行时特定默认值
Render and buildpacks may set defaults (verify in your service’s Environment tab):
| Runtime | Notable defaults |
|---|---|
| Node.js | |
| Python | |
| Ruby | |
| Go | |
| Rust | |
Always bind HTTP servers to and (or the stack’s documented port env) unless using a static site or custom Docker entrypoint.
0.0.0.0PORTRender与buildpack可能会设置默认值(请在服务的环境标签页中验证):
| 运行时 | 值得注意的默认值 |
|---|---|
| Node.js | |
| Python | |
| Ruby | |
| Go | |
| Rust | |
除非使用静态站点或自定义Docker入口点,否则请始终将HTTP服务器绑定到**和**(或栈文档中指定的端口环境变量)。
0.0.0.0PORTCommon Issues
常见问题
- Everything is a string — is truthy in many parsers; use explicit comparison or typed config loaders.
DEBUG=false - — Default behavior changed for services created after December 8, 2025. Compare with older services when debugging worker counts; see
WEB_CONCURRENCY.references/platform-variables.md - Undocumented variables — Names and semantics may change; do not depend on undocumented injection for critical logic.
RENDER_* - Blueprint vs Dashboard drift — Editing only does not retroactively apply
render.yamlprompts on update; merge strategy for env keys is easy to misunderstand—test in a scratch service.sync: false - Secret file paths — Code must read ; wrong paths or missing mounts usually show as file-not-found at runtime.
/etc/secrets/<filename>
- 所有值都是字符串 — 在许多解析器中会被视为真值;请使用显式比较或类型化配置加载器。
DEBUG=false - — 对于2025年12月8日之后创建的服务,默认行为已更改。调试工作进程数量时请与旧服务对比;详情请查看
WEB_CONCURRENCY。references/platform-variables.md - 未记录的变量 — 名称与语义可能会更改;不要依赖未记录的注入变量实现关键逻辑。
RENDER_* - Blueprint与仪表板配置漂移 — 仅编辑不会在更新时回溯应用
render.yaml提示;环境键的合并策略容易被误解——请在测试服务中验证。sync: false - 密钥文件路径 — 代码必须读取****;错误的路径或缺失的挂载通常会在运行时显示为文件未找到。
/etc/secrets/<filename>
References
参考资料
- — Complete Blueprint
references/wiring-reference.mdwiring, YAML examples, precedence, edge casesenvVar - — Injected variables (build vs runtime), language versions, concurrency, reading vars from code
references/platform-variables.md
- — 完整的Blueprint
references/wiring-reference.md关联、YAML示例、优先级与边缘情况envVar - — 注入变量(构建时vs运行时)、语言版本、并发、从代码中读取变量
references/platform-variables.md
Related Skills
相关技能
- render-blueprints — Full Blueprint authoring, validation, multi-service layouts
- render-deploy — First deploy, repo requirements, MCP vs YAML
- render-web-services — Ports, health checks, scaling behavior tied to env-driven servers
- render-blueprints — 完整的Blueprint编写、验证、多服务布局
- render-deploy — 首次部署、仓库要求、MCP与YAML对比
- render-web-services — 端口、健康检查、与环境驱动服务器相关的扩缩容行为