Open port for space to connect to PostgreSQL
Hi@chris-rannou,Could you open the port5432for this space:Defi Ai 2022 - a Hugging Face Space by vnghiaas I need to connect to a PostgreSQL database ?Thank you very much !
2023-01-18T15:56:29Z
hi@anon86412018are you sure your DB service is running at34.155.175.170:5432? if you’re trying to access the DB from space, you don’t need that port to be open, however on your Space log it states timeout trying to reach your db server
2023-01-18T16:13:59Z
Hi@radames, I am quite sure my DB service is running at34.155.175.170:5432because the same code works on my machine. It is a Google Cloud SQL instance (I already opened the DB to every IP and port by0.0.0.0/0on GCP side), maybe that is the reason why I have this error ?
2023-01-18T19:29:57Z
ok you’re right, you might need outgoing port access, currently only 80 and 443, we’ll get back to you soon.
2023-01-19T15:42:29Z
Hi@anon86412018,Port 5432 is now open.
2023-01-19T19:13:27Z
hmmm, unfortuntately, I still can not access to my DB instance. I also add a command to check if the DB is ready bypg_isready. And I found that when building the image, the connection is fine, but it failed while the space is running.You can see the log here:Defi Ai 2022 - a Hugging Face Space by vnghiaDo the port need to be opened twice for building and running or there is something else ?
2023-01-20T04:56:13Z
Hi@anon86412018,I had a similar issue when integrating my Hugging Face Space with my AWS instance.I later found that Hugging Face Space only approves for the privileged port, which is below 1024.I think this is for security reason, and I suggest that you change your SQL server port open with privileged port.For now, I switched the service port to 80, but I remembered that it is fine if the port number is below 1024.Ref for my previous issue:Is there a way to call external gRPC service?SpacesI was planning to deploy a demo on Huggingface Space, but ran into a bit of an issue. 
So, my demo partially depends on a gRPC service that I have deployed on an AWS instance. When I tried test running it, it just timed out with “Failed to pick subchannel” so I am guessing that there is an issue when trying to call a remote gRPC service from Huggingface Space. When I tested my demo by having the same setup in my local computer as I did in Huggingface Space, I had no issues. I also checked to see…
2023-01-20T10:49:14Z
Hi@deepkyuI dont think so because@chris-rannouhas already opened the port and my code can connect to the database while building the Docker image but not while running. I am suspecting there are some bugs with the Docker space
2023-01-20T13:49:37Z
@anon86412018Oh I see. that’s also one of weird situations…From my experience, I concluded that there were some outbound policies in Hugging Face Space server which blocks unprivileged ports. At that time, my docker container at my AWS instance communicates well from other servers’ request except the HF Space.I’m sorry for not being helpful tho.Hope it works out
2023-01-20T14:24:12Z
hi@anon86412018and@deepkyu, we’ve changed the rules and we’ll enable 5432, 27017 in addition to 80, 443. Sorry@anon86412018I don’t think it’s in prod yet. I’ll ping you here. Thanks
2023-01-20T18:10:02Z
hi@anon86412018it should be fixed now, thanks for the patience
2023-01-20T18:25:31Z
Thank you very much !
2023-05-03T10:21:11Z
Hey@radamesthanks for opening up 5432. I’m hoping to use ElasticSearch (9243) and Papertrail logging (45454) for my app. Would it be possible to open up those 2 ports as well in addition to5432?
2023-05-04T16:54:20Z
the ports 5432, 9200 and 45454 are now open
2023-05-04T16:55:38Z
Sorry my apologies I mean 9243 not 9200. I believe that’s the port Elastic uses. Thanks so much!
2023-05-04T16:57:24Z
I see, I guess the default ES port is 9200 and it’s been open already, could you change it on your app?
2023-05-04T17:34:34Z
Ah we’re running our app onelastic.coand that’s the port they gave us unfortunately. I think it might be quite tricky for us to change the port, it’ll also have a bit of downstream impact on all our other services which we’d have to factor in.
2023-05-05T16:54:03Z
hi@kmfoda, the requested ports are open now, please try it again. Thanks
2023-05-05T18:01:45Z
Hi@radames, amazing that worked now! Thank you very much for your help!