Can't connect to Postgres database over public wifi

ama
PRO

2 months ago

I am connecting to my Postgres database via the DATABASE_PUBLIC_URL environment variable, and that works fine over private networks, but not on public wifi networks. I receive the below error:

Error: connect ETIMEDOUT someaddress:someport

at <unknown> (Error: connect ETIMEDOUT someaddress:someport

) {

errno: -60,

code: 'ETIMEDOUT',

syscall: 'connect',

address: 'someaddress',

port: someport

}

Solved$10 Bounty

6 Replies

lofimit
HOBBY

2 months ago

Hey, it's likely for the public WiFi you're currently on to be blocking the Postgres port (usually 5432), so your connection times out. Private networks don't block it, but public ones often do for security.
Try using a VPN or set up a SSH tunnel to get around the restriction.
Also, even though probably not the issue, check if Railway is restricting your IP as public WiFi IPs are often reported as spam and such and blocked by a few services.


mdrooker
HOBBY

2 months ago

Im having the same issue on a few different networks. Ive tried NordVPN just to dblCheck.


lofimit

Hey, it's likely for the public WiFi you're currently on to be blocking the Postgres port (usually 5432), so your connection times out. Private networks don't block it, but public ones often do for security.Try using a VPN or set up a SSH tunnel to get around the restriction.Also, even though probably not the issue, check if Railway is restricting your IP as public WiFi IPs are often reported as spam and such and blocked by a few services.

ama
PRO

2 months ago

I'm thinking that I'm developing locally, while on this public wifi, and so that's why it's failing?

I'm trying allow connections from a backend, and a VPN or SSH feels like not getting to the heart of the problem. Tons of people are on this particular public wifi connection (it's like a Starbucks) and so I think there must be a simpler way to address this (or I'm looking at the wrong problem).

How would I test for: "check if Railway is restricting your IP"? Thanks for the suggestions!


ama

I'm thinking that I'm developing locally, while on this public wifi, and so that's why it's failing?I'm trying allow connections from a backend, and a VPN or SSH feels like not getting to the heart of the problem. Tons of people are on this particular public wifi connection (it's like a Starbucks) and so I think there must be a simpler way to address this (or I'm looking at the wrong problem).How would I test for: "check if Railway is restricting your IP"? Thanks for the suggestions!

smolpaw
HOBBYTop 5% Contributor

2 months ago

Go to your project and deploy a "nginx static site" template. A public url should be generated, try to hit that from your public wifi.
If you receive a response, railway isn't blocking you.

Next, remove the public domain and activate tcp proxy for port 80. You will get a random domain with a random port that is proxying traffic to port 80.
try hitting that now. If it succeeds than it's also not your public wifi.
If it fails it could be that your browser isn't allowing insecure connections so try it with your terminal using this command: curl <your_domain_with_port>

Please follow these steps so I could suggest solutions to you.


ama
PRO

2 months ago

I did these:

Go to your project and deploy a "nginx static site" template. A public url should be generated, try to hit that from your public wifi.
If you receive a response, railway isn't blocking you.

Next, remove the public domain and activate tcp proxy for port 80. You will get a random domain with a random port that is proxying traffic to port 80.
try hitting that now. If it succeeds than it's also not your public wifi.

And was able to connect (to confirm, I attempted connecting via web browser).

I did
curl telnet://{Public Networking Port from Postgres Image -> Settings -> Networking}, and that hung. To confirm, that url does NOT end in 5432, but it points to 5423 here:

I also tried

nc -vz myurl.proxy.rlwy.net 5432

and that hung too.

So I think this must mean that connections to 5432 is blocked on this public network, right?

Attachments


smolpaw
HOBBYTop 5% Contributor

2 months ago

Yes. This is pretty common in a lot of public places. I have experienced these in airports too. This is your corporate wifi allowing connections only on port 80 and 443.


Status changed to Solved chandrika about 2 months ago