# App won't connect to backend

**URL:** <https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898>\
**Category:** React Native\
**Created:** [October 12, 2021, 12:49pm UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898 "2021-10-12T12:49:10Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![sufian.babri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sufian.babri/32/1028_2.png) [@sufian.babri](https://forum.codewithmosh.com/u/sufian.babri)\
**Post date:** [January 21, 2022, 5:26am UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/23 "2022-01-21T05:26:55Z")

</div>

Files such as package.json, package-lock.json, etc are missing.

If you are not comfortable with git, you can simply remove the “node\_modules” folders from both your mobile and web folders, then zip them (mobile and server directories) and upload them to Dropbox or Google Drive.

When working with git, we add the node\_modules folder to .gitignore since we can download these packages by running `npm install`.

**PS: please zip them instead of rar, or put the whole folder on Dropbox.**

---

<div class="post-metadata">

**Author:** ![ShashankSai](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@ShashankSai](https://forum.codewithmosh.com/u/ShashankSai)\
**Post date:** [January 21, 2022, 8:53am UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/24 "2022-01-21T08:53:40Z")

</div>

Even I am getting the same problem.  
Object {  
“config”: Object {  
“adapter”: [Function xhrAdapter],  
“baseURL”: “192.168.137.1:9000/api”,  
“data”: undefined,  
“headers”: Object {  
“Accept”: “application/json”,  
},  
“maxBodyLength”: -1,  
“maxContentLength”: -1,  
“method”: “get”,  
“params”: Object {},  
“timeout”: 0,  
“transformRequest”: Array [  
[Function transformRequest],  
],  
“transformResponse”: Array [  
[Function transformResponse],  
],  
“transitional”: Object {  
“clarifyTimeoutError”: false,  
“forcedJSONParsing”: true,  
“silentJSONParsing”: true,  
},  
“url”: “/listings”,  
“validateStatus”: [Function validateStatus],  
“xsrfCookieName”: “XSRF-TOKEN”,  
“xsrfHeaderName”: “X-XSRF-TOKEN”,  
},  
“data”: null,  
“duration”: 14,  
“headers”: null,  
“ok”: false,  
“originalError”: [Error: Network Error],  
“problem”: “NETWORK\_ERROR”,  
“status”: null,  
}

I was able to call the backend through browsers.  
Tried changing IPV4 IPV6 and gateway IP addresses

---

<div class="post-metadata">

**Author:** ![sufian.babri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sufian.babri/32/1028_2.png) [@sufian.babri](https://forum.codewithmosh.com/u/sufian.babri)\
**Post date:** [January 21, 2022, 11:43am UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/25 "2022-01-21T11:43:00Z")

</div>

Can you upload the mobile and backend code to Dropbox (just make sure that node\_modules folder is not uploaded as it will increase the file size)?

---

<div class="post-metadata">

**Author:** ![ShashankSai](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@ShashankSai](https://forum.codewithmosh.com/u/ShashankSai)\
**Post date:** [January 21, 2022, 12:02pm UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/26 "2022-01-21T12:02:06Z")

</div>

> **[GitHub - SaiTejaShashank/DoneWithIt](https://github.com/SaiTejaShashank/DoneWithIt)**
>
> Contribute to SaiTejaShashank/DoneWithIt development by creating an account on GitHub.

I have uploaded the project and its backend without node modules here. Please try to help me

---

<div class="post-metadata">

**Author:** ![sufian.babri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sufian.babri/32/1028_2.png) [@sufian.babri](https://forum.codewithmosh.com/u/sufian.babri)\
**Post date:** [January 21, 2022, 8:38pm UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/27 "2022-01-21T20:38:13Z")

</div>

I ran your code. You just need to update your baseURL line in the client.js to this:

```auto
const apiClient=create({baseURL:"http://192.168.137.1:9000/api"});

```

---

<div class="post-metadata">

**Author:** ![ShashankSai](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@ShashankSai](https://forum.codewithmosh.com/u/ShashankSai)\
**Post date:** [January 22, 2022, 3:55am UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/28 "2022-01-22T03:55:07Z")

</div>

Thank you bro. It is working. The problem is with giving wrong ip address. Thats a lot

---

<div class="post-metadata">

**Author:** ![Tobiken](https://avatars.discourse-cdn.com/v4/letter/t/b4bc9f/32.png) [@Tobiken](https://forum.codewithmosh.com/u/Tobiken)\
**Post date:** [February 25, 2022, 8:30pm UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/29 "2022-02-25T20:30:37Z")

</div>

You are a savior my friend! thank you \<3

---

<div class="post-metadata">

**Author:** ![chandanshaw2050](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@chandanshaw2050](https://forum.codewithmosh.com/u/chandanshaw2050)\
**Post date:** [March 22, 2022, 12:43pm UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/30 "2022-03-22T12:43:53Z")

</div>

Hey Sufian, can you please help me out with my code my backend is also not getting connected I am trying it since 3 days. I have attached below the link to my files. Please help me out

link: [React Native.zip - Google Drive](https://drive.google.com/file/d/1cDRjxUFA4_d2KkbjyjmdqJUGSU5oNFRp/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![lorenco](https://avatars.discourse-cdn.com/v4/letter/l/a587f6/32.png) [@lorenco](https://forum.codewithmosh.com/u/lorenco)\
**Post date:** [March 24, 2022, 7:14pm UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/33 "2022-03-24T19:14:39Z")

</div>

hey everyone so I was getting the Network Error before, and couldn’t figure out why it wasn’t working. I was able to use localhost and 127.0.0.1 (just learned they are the same thing) but as Mosh said, using localhost won’t work for android devices.

I then found a post in the React Native Developers discord channel where someone said that you can’t fetch from localhost because localhost is your own phone (if you try using localhost and running the app on your own physical iOS device, you’ll see that you still get the network error even though it works in the simulator). The same person who posted the above mentioned message then said that you need to use your computer’s LAN IP address. I had been using the IP address i found when I googled “what is my IP address” since I didn’t know there were different types/purposes.

After following the instructions on the following site ([get your LAN IP address in MacOSX](https://osxdaily.com/2010/08/08/lan-ip-address-mac/)), and I have fixed the issue and can attest that using my LAN IP address allows my iOS simulator, iOS physical device, AND android simulator to successfully connect to my API.

As a reminder, you’ll have to use the LAN IP address in the baseURL in client.js in the client AND assetsBaseUrl in development.json in the API.

I hope this helps!

---

<div class="post-metadata">

**Author:** ![sufian.babri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sufian.babri/32/1028_2.png) [@sufian.babri](https://forum.codewithmosh.com/u/sufian.babri)\
**Post date:** [March 27, 2022, 7:28am UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/34 "2022-03-27T07:28:21Z")

</div>

Please refer to lorenco’s comment. He’s right that you need to put in your machine’s public IP address in place of localhost or 127.0.0.1.

---

<div class="post-metadata">

**Author:** ![chandanshaw2050](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@chandanshaw2050](https://forum.codewithmosh.com/u/chandanshaw2050)\
**Post date:** [March 27, 2022, 7:37pm UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/35 "2022-03-27T19:37:34Z")

</div>

Hello, I have also tried searching for my IP address on google as I am a Windows user can you suggest to me a website where I can get exactly what I am looking for?

---

<div class="post-metadata">

**Author:** ![lorenco](https://avatars.discourse-cdn.com/v4/letter/l/a587f6/32.png) [@lorenco](https://forum.codewithmosh.com/u/lorenco)\
**Post date:** [March 30, 2022, 1:04am UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/36 "2022-03-30T01:04:11Z")

</div>

this might be helpful, i’m not sure how up-to-date it is though. let us know in case others are in the same boat as you! [How to find your LAN IP address - YouTube](https://www.youtube.com/watch?v=XtoBBrHruQU)

---

<div class="post-metadata">

**Author:** ![Asotes](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@Asotes](https://forum.codewithmosh.com/u/Asotes)\
**Post date:** [April 29, 2022, 3:15pm UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/37 "2022-04-29T15:15:21Z")

</div>

I really want to connect with you Sir,…can you just send me a message on my email  
[forexpave@gmail.com](mailto:forexpave@gmail.com)

---

<div class="post-metadata">

**Author:** ![Neeraj09](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@Neeraj09](https://forum.codewithmosh.com/u/Neeraj09)\
**Post date:** [January 22, 2023, 11:48am UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/38 "2023-01-22T11:48:43Z")

</div>

At the client.js file, replace the ip with your _Wireless LAN IP_, that can be found using **ipconfig** on windows command terminal and **ifconfig** on linux.

---

<div class="post-metadata">

**Author:** ![tarsandor](https://avatars.discourse-cdn.com/v4/letter/t/a9adbd/32.png) [@tarsandor](https://forum.codewithmosh.com/u/tarsandor)\
**Post date:** [February 14, 2023, 7:22pm UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/39 "2023-02-14T19:22:11Z")

</div>

Hello bebo7,  
Can you please tell us if you could connect to the backend?  
I have the same problem as you.

---

<div class="post-metadata">

**Author:** ![tarsandor](https://avatars.discourse-cdn.com/v4/letter/t/a9adbd/32.png) [@tarsandor](https://forum.codewithmosh.com/u/tarsandor)\
**Post date:** [February 18, 2023, 3:18pm UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/40 "2023-02-18T15:18:20Z")

</div>

Well, I tried all of the possibilities, I used IPv6, './listings/, localhost.  
I also downloaded the zipped files and tried them, every time I got “problem”: “NETWORK\_ERROR”.  
I don’t know Mosh why didn’t figured out a better solution for backend, as I see a lot of people has the same problem. Is there somebody who resolved the problem?

The response of the request:  
Object {  
“config”: Object {  
“adapter”: [Function xhrAdapter],  
“baseURL”: “[http://192.168.0.10:9000/api”](http://192.168.0.10:9000/api%E2%80%9D),  
“data”: undefined,  
“headers”: Object {  
“Accept”: “application/json”,  
},  
“maxContentLength”: -1,  
“method”: “get”,  
“params”: Object {},  
“timeout”: 0,  
“transformRequest”: Array [  
[Function transformRequest],  
],  
“transformResponse”: Array [  
[Function transformResponse],  
],  
“url”: “/listings”,  
“validateStatus”: [Function validateStatus],  
“xsrfCookieName”: “XSRF-TOKEN”,  
“xsrfHeaderName”: “X-XSRF-TOKEN”,  
},  
“data”: null,  
“duration”: 69619,  
“headers”: null,  
“ok”: false,  
“originalError”: [Error: Network Error],  
“problem”: “NETWORK\_ERROR”,  
“status”: null,  
}

---

<div class="post-metadata">

**Author:** ![sufian.babri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sufian.babri/32/1028_2.png) [@sufian.babri](https://forum.codewithmosh.com/u/sufian.babri)\
**Post date:** [February 22, 2023, 4:39am UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/41 "2023-02-22T04:39:45Z")

</div>

Try using your public IP address as per [this comment](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/33). IP addresses starting in the form 192.xx.xx.xx are not public addresses.

---

<div class="post-metadata">

**Author:** ![irfan](https://avatars.discourse-cdn.com/v4/letter/i/8797f3/32.png) [@irfan](https://forum.codewithmosh.com/u/irfan)\
**Post date:** [October 4, 2023, 4:04pm UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/42 "2023-10-04T16:04:38Z")

</div>

same problem here too…  
read and implemented all the comments step by step… but no success… if someone has solved this problem please share here… will be gratefull…

---

<div class="post-metadata">

**Author:** ![irfan](https://avatars.discourse-cdn.com/v4/letter/i/8797f3/32.png) [@irfan](https://forum.codewithmosh.com/u/irfan)\
**Post date:** [October 5, 2023, 8:17am UTC](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898/43 "2023-10-05T08:17:59Z")

</div>

Solved the same issue… took the following steps…

1. Reinstalled backend.
2. Used ipconfig to get IPv4 address.

hope this solves it for all…

[Previous page](https://forum.codewithmosh.com/t/app-wont-connect-to-backend/7898.md?page=1)
