Rails 8 Database Connection to Supabase Failing with Error

tim-lynn-clark
PRO

3 months ago

When the application starts, the database connection fails with the following error:

ActiveRecord::ConnectionNotEstablished: connection to server at "2600:1f16:1cd0:3304:2a81:66ed:a170:eb1c", port 5432 failed: Network is unreachable (ActiveRecord::ConnectionNotEstablished)

The connection is to a Supabase postgres database, the same one I am hitting from me local machine in development.

Railway app is configured identically and is running in RAILS_ENV=development just like local dev. The issue seems to be the fact that the Railway app cannot access external resources on the internet.

The IP address given is an IPV6, which the app says it is configured for. So I am not sure what the deal is.

Solved

15 Replies

parmstar
EMPLOYEE

3 months ago

Hi,

Have you had a look through this: https://docs.railway.com/guides/public-networking
https://docs.railway.com/reference/public-networking#how-do-i-handle-forwarding-traffic-to-my-exposed-port

Suggesting this for speed - if this doesn't unblock, please provide us consent to look into your project on your next message by saying "I consent to Railway looking into my project".

Thanks!


Status changed to Awaiting User Response railway[bot] 3 months ago


tim-lynn-clark
PRO

3 months ago

I consent to Railway looking into my project


Status changed to Awaiting Railway Response railway[bot] 3 months ago


tim-lynn-clark
PRO

3 months ago

Since I have to have the portal up for testing by 2PM EST today. I also attempted to deploy it to Digital Ocean. Same issue with it not want to connect to Supabase, even though I can connect my local dev to it using the same connection string.

-03-24 16:22:03] Caused by:

[2025-03-24 16:22:03] PG::ConnectionBad: connection to server at "2600:1f16:1cd0:3304:2a81:66ed:a170:eb1c", port 5432 failed: No route to host (PG::ConnectionBad)

[2025-03-24 16:22:03] Is the server running on that host and accepting TCP/IP connections?

[2025-03-24 16:22:03]


3 months ago

Hello,

We don't support IPv6 outbound, you would need to use a supabase address that is IPv4 only.

Best,
Brody


Status changed to Awaiting User Response railway[bot] 3 months ago


tim-lynn-clark
PRO

3 months ago

The connections string uses a domain that translates to either IPv6 or IPv4 according to Supabase. Any idea how you are supposed to handle that?


Status changed to Awaiting Railway Response railway[bot] 3 months ago


tim-lynn-clark
PRO

3 months ago

Did some digging, looks like Supabase has some other connection strings with domains that are not bound to IPv6.

I did not see the fact that IPv6 is not supported by Railway anywhere in the documentation I found.


3 months ago

I don't think we advertise that outbound IPv6 is not supported, but I'll make a note of that.

Hopefully using an IPv4 only address solves the issue for you, I know it has solved it for other users who use supabase.


Status changed to Awaiting User Response railway[bot] 3 months ago


tim-lynn-clark
PRO

3 months ago

The database connection errors seem to be resolved, the app deploys, but I get 502 errors but cannot see in the logs what is the cause. I just added the RAILS_LOG_TO_STDOUT to the env variables to see if it can tell me something. Do you have the ability to see more detailed reasons for the 502?


Status changed to Awaiting Railway Response railway[bot] 3 months ago



Status changed to Awaiting User Response railway[bot] 3 months ago


3 months ago

I went ahead and adjusted your target port for you, your website is now online.


tim-lynn-clark
PRO

3 months ago

Can you explain to me what that is about? This setup was from a template and I just deployed a different rails app with similar config minus the Supabase instead of Postgres. The ports in the procfile were the same.


Status changed to Awaiting Railway Response railway[bot] 3 months ago


tim-lynn-clark
PRO

3 months ago

I am new to Railway, so, learning curve


3 months ago

This docs section specifically -

https://docs.railway.com/reference/errors/application-failed-to-respond#target-port-set-to-the-incorrect-value

You didn't have a target port set, I set it to port 80 for you.


Status changed to Awaiting User Response railway[bot] 3 months ago


tim-lynn-clark
PRO

3 months ago

Thank you for your assistance Brody.


Status changed to Awaiting Railway Response railway[bot] 3 months ago


3 months ago

No problem!


Status changed to Awaiting User Response railway[bot] 3 months ago


Status changed to Solved brody 3 months ago


Rails 8 Database Connection to Supabase Failing with Error - Railway Help Station