a year ago
Hi,
Suddenly I can't connect from my app to postgres by using Private Networking
But seems fine using Public Networking
17 Replies
a year ago
Yes, that's the error, mate.
Initially I was able to connect my app to Postgre via internal networking, somehow after I rebuilt several jobs I couldn't connect internally, has anyone experienced a similar incident?
Currently I use public networking to overcome this 😄
I'll try again later then
a year ago
you haven't provided a specific error message, there's nothing concrete for me to go off of.
a year ago
I appear to be having the same issue. I just finished migrating my postgres plugin db to the service db. The service private db url was suggested as postgres.railway.internal. When I used that for my other service to connect to I get the following error:
Error initializing database error="dial tcp: lookup postgres.railway.internal on 8.8.8.8:53: no such host"
The URL it was using was copied directly from the DATABASEPRIVATEURL variable in that service. If I switch to the proxied public one in DATABASE_URL the service connects. With the old plugin, I was using the private URL and it worked just fine.
The only thing different about my setup now (other than the obvious switch to the new postgres db) is that the old plugin is still hanging around (I didn't delete it yet), in case maybe that is interfering. Not sure if @golz also has the migrated one lingering in their setup, or we are both just experiencing some other issue.
a year ago
There is little clarification needed here, the old plugins did not have a private URL and never were a part of the private network.
for that specific error, you must add a 3-second sleep to your start command or before you connect to the database.
a year ago
Apologies, I likely misspoke about the private network bit regarding the plugin. Since they disabled it, I couldn't actually see which URL I had used (and I haven't looked at this since October). So I made the assumption that I had that option previously.
Regarding the 3-second sleep, I'll try that (very new to a lot of this). Thanks!
a year ago
Error initializing database error="dial tcp: lookup postgres.railway.internal on 8.8.8.8:53: no such host"
It looks like you're on an Alpine-based container. Private networking currently does not play well with Alpine containers (we have a fix in progress), so you'll need to workaround it by adding a ENABLE_ALPINE_PRIVATE_NETWORKING=true
service variable.
Adding the sleep is also highly recommended on top of that!
a year ago
i've just started with railway and got into the same problem. have rails stack with PG and trying to use private database URL. Where exactly I need to enable ENABLEALPINEPRIVATE_NETWORKING, on Rails service (using Ruby nix) or Postgres? Also, if I use public URL, whats the performance/latency overhead vs internal one? Kind of bummer that it doesn't work out of the box
a year ago
the variable ray mentioned would need to be added to your service variables
using the public url would be subject to egress fees, so its recommended you use the internal url.
Kind of bummer that it doesn't work out of the box
agree, and the team is hands on keyboard for a fix
a year ago
i've tried adding to both services, ruby and postgres but it doesn't help
a year ago
i'm trying to migrate db from CLI:
railway run bash
env | grep DATABASE
DATABASE_URL=postgresql://postgres:@postgres.railway.internal:5432/railway?connect_timeout=300
bash-3.2$ rails db:migrate
I, [2024-02-29T00:12:14.087711 #23980] INFO -- : [dotenv] Loaded .env
bin/rails aborted!
ActiveRecord::NoDatabaseError: We could not find your database: railway. Available database configurations can be found in config/database.yml. (ActiveRecord::NoDatabaseError)
To resolve this error:
- Did you not create the database, or did you delete it? To create the database, run:
bin/rails db:create
- Has the database name changed? Verify that config/database.yml contains the correct database name.
Caused by:
PG::ConnectionBad: could not translate host name "postgres.railway.internal" to address: nodename nor servname provided, or not known (PG::ConnectionBad)
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
as you see it cant resolve the hostname
a year ago
railway run
- runs commands locally, not on railway.
for this use-case you would need to use the public url.
7 months ago
Is this still an issue? I'm trying to spin up a Redis instance on Railway and would like to connect to it. But the service simply fails to connect with ENOTFOUND error. How do I know if Redis uses alpine or not?
[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis.railway.internal
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
7 months ago
Actually it seems I'm unable to connect with neither railway.internal or the public endpoint
7 months ago
Found the fix here https://docs.railway.app/guides/private-networking#known-configuration-requirements-for-ipv6, it was for a live service
Status changed to Solved brody • 8 months ago