Railway App > Railway MySQL connection - but in different projects

rjbathgate
PRO

a month ago

Hey,

I have this set up:

Project 1 > App 1 (web app)

Project 2 > MySQL

To connect my web app to MySQL I thought I'd be able to use either:
${{ MySQL.MYSQL_URL }}
or
mysql.railway.internal

as my DB_HOST variable in my web app.

But that fails:

2002 - php_network_getaddresses: getaddrinfo for mysql.railway.internal failed: Name or service not known

My understanding is that this is because the App and the MySQL are in different projects within my Railway account.

If I use the Public URL for MySQL, everything works - but using that I am going to be charged egress fees - even though everything is in Railway.

Is there a way to have the web app connect the MySQL container internally whilst they are both in different projects - i.e. incurring no egress charges?

Reading this thread:
https://station.railway.com/questions/understanding-ram-and-egress-usage-763a28f6

it suggests the DATABASE_PRIVATE_URL, but I don't see that defined anywhere in my MySQL settings and that thread is oldish...

End goal is a single MySQL server housing a bunch of databases for different web apps, whcih might be spread over a few different projects.

Thanks in advance

Solved$10 Bounty

3 Replies

a month ago

Hello,

As far as I know there is no way to setup private networking between different Railway project since they all have their own overlay network. That might be a good feature tho.

In your thread, Ray made it clear that you had to have your apps in the same project.

You could setup a tunnel (Wireguard for exemple) to increase the security and privacy of your connections but you'll still have to pay for Ingress / Egress.


mateodemuynck

Hello,As far as I know there is no way to setup private networking between different Railway project since they all have their own overlay network. That might be a good feature tho.In your thread, Ray made it clear that you had to have your apps in the same project.You could setup a tunnel (Wireguard for exemple) to increase the security and privacy of your connections but you'll still have to pay for Ingress / Egress.

rjbathgate
PRO

a month ago

Thanks - and to confirm it I've since found at the bottom of the networking docs that railway.internal only works inside a project.

It would be good if there was an internal solution though as I'm guessing (with no knowledge whatsoever!!) that the infrastructure used between project a and project b is sitting close together!

I'll move things into one project


rjbathgate

Thanks - and to confirm it I've since found at the bottom of the networking docs that railway.internal only works inside a project.It would be good if there was an internal solution though as I'm guessing (with no knowledge whatsoever!!) that the infrastructure used between project a and project b is sitting close together!I'll move things into one project

a month ago

Hey, as mateodemuynck has mentioned, private networking only works within the same Railway project. It is best to use groups to group services together than separating them across different projects, if they share common dependencies, such as a central database, together.


Status changed to Solved uxuz about 1 month ago


Railway App > Railway MySQL connection - but in different projects - Railway Help Station