Back

How to connect with Appwrite server on local machine

  • 0
  • Android
Amarjot
6 Apr, 2023, 06:56

@Meldiron@Steven @joeyouss Hey, I am new to Appwrite & try to build a simple project on android(kotlin) by using appwrite as a backend server for database. But i am unable connect my project with appwrite on a local machine as my emulator and server runs on same machine.  I got the Exceptions like: Caused by: java.net.ConnectException: failed to connect to /192.168.18.98 (port 443) from /10.0.2.16 (port 51364) after 10000ms: isConnected failed: ECONNREFUSED (Connection refused) I tried Postman software to hit its api, read its official docs,  tried to resolve it by adding : android:usesCleartextTraffic="true" into AndroidManifest. xml in the Android studio, changed IP address by getting it from network (Settings), also added .setSelfSigned(status = true) in client, in endpoint i changed http to https, I cleaned and rebuild my project so many times….But nothing helped me. Could you guys please suggest me something that will sort my problem.

TL;DR
User is having trouble connecting their Android app to Appwrite server on their local machine. They tried various solutions such as using different IP addresses, adding a permission in the AndroidManifest.xml file, and setting self-signed status to true in the client code, but nothing worked. They are experiencing a connection timeout exception. Solution: It seems that the issue is related to the emulator and network conflict. It is recommended to try using the computer's IP address to access the server from the emulator. Additionally, restarting Appwrite and trying different browsers may also help resolve the issue.
Maniac_Fighter
6 Apr, 2023, 07:50

Is your appwrite running?

Amarjot
6 Apr, 2023, 08:25

yes, Appwrite console is running in my browser

Maniac_Fighter
6 Apr, 2023, 08:30

Default ports?

Maniac_Fighter
6 Apr, 2023, 08:31

To access from the emulator you need to use your computer ip address to acesss it

Maniac_Fighter
6 Apr, 2023, 08:31

Could you share your client initialisation code

Amarjot
6 Apr, 2023, 08:33

object Client { lateinit var client: Client fun create(context: Context) { client = Client(context) .setEndpoint(Config.ENDPOINT) .setProject(Config.PROJECT) .setSelfSigned(status = true) }}

Amarjot
6 Apr, 2023, 08:34

const val ENDPOINT = "https://192.168.18.98/v1"

Drake
6 Apr, 2023, 13:59

How to connect with Appwrite server on local machine

Amarjot
7 Apr, 2023, 11:30

@Maniac_Fighter

Maniac_Fighter
7 Apr, 2023, 12:16
Amarjot
8 Apr, 2023, 05:18

Hey @Maniac_Fighter, when I tried by adding http://192.168.1.98/v1, I got the exception: java.net.SocketTimeoutException: failed to connect to /192.168.1.98 (port 80) from /10.0.2.16 (port 52474) after 10000ms

Maniac_Fighter
8 Apr, 2023, 05:32

if you use this url and visit in the browser (without v1 endpoint) are you able to access the appwrite console??

Amarjot
8 Apr, 2023, 06:10

@Maniac_Fighter we have tried (http://192.168.18.98/ (Its my ip address from network in settings) and http://192.168.1.98/) with and without v1 , its not working

We are able to see the console in browser with http://localhost/console/organization-org_id only

tried changing the localhost with ip address too, didn't work

Maniac_Fighter
8 Apr, 2023, 06:12

so the ip address is incorrect then. could you share the result of ipconfig

Amarjot
8 Apr, 2023, 06:28
Amarjot
8 Apr, 2023, 06:28

@Maniac_Fighter Please check the screen shots

Amarjot
8 Apr, 2023, 06:30

FYI: I'm using mac mini late 2012 (macOS Catalina 10.15.7)

Maniac_Fighter
8 Apr, 2023, 06:39

so I tested on my system, and it works fine on mine

What's the error when you try to access console using the ip address (http://192.168.18.98)

Amarjot
8 Apr, 2023, 06:40

@Maniac_Fighter

Maniac_Fighter
8 Apr, 2023, 06:40

could you try it with different browser

Maniac_Fighter
8 Apr, 2023, 06:44

If it's the same could you restart appwrite and try again. I can't seem to think any other solution for this then

Drake
8 Apr, 2023, 16:04

It could be a docker network conflict...in your emulator, does 10.0.2.2 work?

Amarjot
10 Apr, 2023, 06:42

No, Its not working in Postman and also in browser gives the same error as above : Safari Can't connect to the server

Drake
10 Apr, 2023, 15:31

Did you try with 10.0.2.2 in your emulator?

The IP could be failing due to a network conflict. Would you try running this:

TypeScript
docker inspect --format '{{.Name}}:{{range $k, $v := .IPAM.Config}}{{printf "\n  %s" $v.Subnet}}{{end}}{{printf "\n"}}' `docker network ls --filter 'driver=bridge' -q`
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more