Mastra private networking not working

lukasthrane
HOBBY

2 months ago

Hey,

Im trying to set up a mastra instance and connect to it from my other services. Everything works locally, but on railway it doesn't want to connect (I get no logs in the mastra instance, and get "waiting for mastra to be ready" in all my other services since they cant connect to it). I have set the internal mastra URL to:

Ive also tested with https.

The mastra logs show this:
> @graidable/mastra@1.0.0 start

> mastra start

INFO [2025-07-21 15:35:55.628 +0000] (Mastra): Mastra API running on port http://0.0.0.0:4111/api

Opening a public networking and generating a url at:

The services are all in the same project, and I've connected everything else and it works fine. Only mastra doesn't want to connect for some reason, but the public URL works fine? I don't understand why this is happening. Thanks for any help in advance.

Solved$10 Bounty

2 Replies

Railway
BOT

2 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


clashing
HOBBYTop 5% Contributor

2 months ago

If your Mastra server binds to 0.0.0.0 (IPv4), it won't be accessible from other services over the IPv6-only private network.

You can: Update your Mastra server config to also bind to IPv6 (typically :: or ::0). Depending on your framework or server, you may need to add:

server: {

port: parseInt(process.env.PORT || '4111', 10),

host: '::', // Binds to all IPv6 and IPv4 addresses if supported

}

As shared by the Railway Bot, this might help you https://docs.railway.com/reference/private-networking


Status changed to Solved chandrika about 1 month ago


Mastra private networking not working - Railway Help Station