Memory issues
nftimm-dev
PROOP

4 months ago

Billing Context

Railway billing shows I'm only using ~77MB average memory (costing $0.77/month) yet experiencing 90%+ heap usage warnings. This confirms the heap is artificially constrained and not using available Pro plan resources.

Questions

  1. Is there a Railway/Nixpacks limitation preventing Node.js memory flags from being applied?

  1. Does the Pro plan have hidden memory restrictions beyond the advertised 8GB?

  1. Is there a specific Railway configuration needed to allow these standard Node.js flags?

  1. Are there logs showing why the flags are being ignored?

What I Need

The Node.js heap to start at 1GB (--initial-old-space-size=1024) and grow up to 8GB (--max-old-space-size=8192) as configured, utilizing the available Pro plan memory.

These are standard, documented Node.js flags that should work in any Node.js hosting environment.

Business Impact

  • Application experiencing constant memory pressure

  • Frequent restarts due to OOM conditions

  • Performance degradation from excessive GC cycles

  • Cannot scale application due to artificial memory constraints

Request

Please investigate why Railway/Nixpacks is ignoring Node.js memory flags and provide guidance on how to properly configure them. If there's a platform limitation, I may need to migrate to a different hosting provider that supports standard Node.js configuration.

Thank you for your help!

Additional Information Available:

  • Full build logs

  • Deploy logs showing memory usage

  • All configuration files (railway.json, nixpacks.toml, package.json)

  • Git repository access if needed

$10 Bounty

5 Replies

Railway
BOT

4 months ago


4 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 4 months ago


Have you tried increasing max memory in service settings?


0x5b62656e5d

Have you tried increasing max memory in service settings?

nftimm-dev
PROOP

4 months ago

It’s already set to 32GB max but yet still crashes with a memory heap of only 200-400mb.


nftimm-dev

It’s already set to 32GB max but yet still crashes with a memory heap of only 200-400mb.

4 months ago

instant crashes wont appear in the metrics tab. what does your railpack or nixpack look like? are you able to provide the logs?


4 months ago

How are you starting your Node.js app? Are you using a custom start command in the Railway UI, is it set in your railway.json or nixpacks config, or are you letting Nixpacks/Railpack auto-detect it?

I ask because I think that's likely the start command is the root of this problem.

You need to pass those Node.js memory flags to the actual start command Railway is using. You do mention you're using railway.json/nixpacks.toml so maybe some conflicts there are causing issues?
If I was in your shoes, I would go through the following steps and make sure there aren't conflicts across your config files.

Fixing this with a prod:start script in package.json

This is the first option I would think of, just use a start:prod script in your package.json

{
  "scripts": {
    "start": "node --initial-old-space-size=1024 --max-old-space-size=8192 dist/app.js"
  }
}

Fixing this in the Railway UI

Go to your service settings -> Deployment -> Start Command and add node --initial-old-space-size=1024 --max-old-space-size=8192 dist/app.js or whatever your typical start command is

Fixing this using config as code / railway.json

You can use a railway.json in your repo to set this with config as code as well:

{
  "$schema": "https://railway.com/railway.schema.json",
  "deploy": {
     // other stuff goes here
    "startCommand": "node --initial-old-space-size=1024 --max-old-space-size=8192 dist/app.js"
  }
}

Fix using environment variables

Add this as a service variable:

NODE_OPTIONS=--initial-old-space-size=1024 --max-old-space-size=8192

This one should work regardless of how your app starts but can be overridden by other configs (like the other 3 options listed above).

After updating your start command, check the deployment logs to confirm those flags are being passed. You should see your app start with those memory settings in the actual start command.

If this still isn't working, can you drop some logs in here showing how your service is built and starts?


Loading...