10 months ago
Hello Railway Support,
I'm experiencing a persistent build failure that I cannot resolve. My Node.js application keeps failing to build with this error:
ERROR: failed to build: failed to solve: secret JWT_SECRET: not found
THE PROBLEM:
Railway's build system (Railpack) is trying to access my JWT_SECRET environment variable during the build phase, but this variable should only be needed at runtime. My application is a simple Node.js/Express app that doesn't require any secrets during npm install or build.
WHAT I'VE TRIED:
1. Deleted and recreated the service completely
2. Disconnected and reconnected the GitHub repository
3. Added all 6 environment variables correctly
4. Created a nixpacks.toml file to explicitly configure the build process
5. Verified no railway.json exists in my GitHub repository
CURRENT STATE:
- Project: freedom-protocol (production environment)
- Service: spectacular-recreation
- Repository: freedomprotocol26-ship-it/freedom-protocol-web
- Branch: main
- Region: us-west2
REPOSITORY STRUCTURE:
- server.js
- package.json (only has "start": "node server.js")
- public/index.html
- database-schema.sql
- nixpacks.toml
- .gitignore
ALL 6 ENVIRONMENT VARIABLES ARE SET:
ANTHROPIC_API_KEY, SUPABASE_URL, SUPABASE_ANON_KEY, JWT_SECRET, NODE_ENV, PORT
REQUEST:
Please investigate why Railway is trying to access secrets during the build phase. There appears to be cached configuration from a previous deployment causing this issue. Can you clear any cached configurations for my project?
Thank you!
3 Replies
10 months ago
The error syntax: failed to solve: secret JWT_SECRET: not found means a build instruction (like RUN --mount=type=secret,id=JWT_SECRET) is being executed. This is most likely coming from your nixpacks.toml . Look for a secrets array inside any phase ([phases.build] or [phases.setup]).
cmds = ["npm run build"]
secrets = ["JWT_SECRET"] # this is the issue, remove it.
darseen
The error syntax: `failed to solve: secret JWT_SECRET: not found` means a build instruction (like `RUN --mount=type=secret,id=JWT_SECRET`) is being executed. This is most likely coming from your `nixpacks.toml` . Look for a `secrets` array inside any phase (`[phases.build]` or `[phases.setup]`). \[[phases.build](http://phases.build)\] cmds = \["npm run build"\] secrets = \["JWT\_SECRET"\] # this is the issue, remove it.
10 months ago
Where do you see the nixpacks.toml content?
aldrinm
Where do you see the nixpacks.toml content?
10 months ago
If you mean do I see his nixpacks.toml , then no, I can't. I just gave an example code sample of what is most likely causing his issue.