Hello everyone, I am trying to connect to my local...
# supabase-kt
c
Hello everyone, I am trying to connect to my local supabase setup from my android app and it’s throwing an issue that says;
GET request to endpoint /rest/v1/mytable failed with exception Permission denied
io.github.jan.supabase.exceptions.HttpRequestException: HTTP request to <http://127.0.0.1:54321/rest/v1/mytable?select=%2A> (GET) failed with message: Permission denied
Any idea what the cause could be please? I can already connect to the database and perform crud operations on the tables in the db (I use DBeaver)
n
Did you add any rule to RLS? https://supabase.com/docs/guides/auth/row-level-security By default everything is denied, AFIK.
c
I couldn’t find a way to do this from the dashboard since I’m using a local dev setup, I could only do this when I was using the online setup. Is there a way to do this when you’re developing offline?
n
Ah, no idea, I've only used the hosted solution.
j
Do you have the internet permission in your manifest?
c
Yeah, I just added that now and still get a similar error;
Copy code
GET request to endpoint /rest/v1/mytable failed with exception Connection refused

io.github.jan.supabase.exceptions.HttpRequestException: HTTP request to <http://127.0.0.1:54321/rest/v1/mytable?select=%2A> (GET) failed with message: Connection refused
u
Base on my understanding, it must create a network like creating a server. I think in local it's only passing token or data for authorization and if not Row level security.
j
The error is a
HttpRequestException
(not a
RestException
) that means the request itself failed/the client couldn't reach the server. Can you open this url in your browser?
c
When I open the url in the browser it returns the expected response, but on the app it fails with the error above
j
So in the android browser the website appears? Which ktor engine are you using?
c
On the browser on my device, when I copy the url in the request and post it and my browser or postman it returns the expected response, but from the app with the sparse client it doesn’t
j
Can you try using Ktor manually and check if the same error appears?
Copy code
HttpClient().get("<http://127.0.0.1:54321/rest/v1/mytable?select=%2A>")
c
yeah, I get a similar error;
java.net.ConnectException: Connection refused
j
So its not really Supabase related, but you could have a look a this or just Google this error. Maybe the localhost is making some problems
c
Thanks Jan. I found the reason for this was because
localhost
wouldn’t work for my devices. I needed to get the address of the device, so for android emulator it is
<http://10.0.2.2:54321>
instead of
localhost:54321
, but for my physical device, I haven’t found a way to reliably get it