{"id":738,"hash":"353ca5d0c7e5b9284756b10111f04db91e333d4d7936c54be1eb905005bc29b2","pattern":"Network error with axios and react native","full_message":"I have created an API endpoint using the Django python framework that I host externally. I can access my endpoint from a browser (mydomain.com/endpoint/) and verify that there is no error. The same is true when I run my test django server on locally on my development machine (localhost:8000/endpoint/). When I use my localhost as an endpoint, my json data comes through without issue. When I use my production domain, axios gets caught up with a network error, and there is not much context that it gives... from the debug console I get this:\n\nError: Network Error\n    at createError (createError.js:16)\n    at XMLHttpRequest.handleError (xhr.js:87)\n    at XMLHttpRequest.dispatchEvent (event-target.js:172)\n    at XMLHttpRequest.setReadyState (XMLHttpRequest.js:554)\n    at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:387)\n    at XMLHttpRequest.js:493\n    at RCTDeviceEventEmitter.emit (EventEmitter.js:181)\n    at MessageQueue.__callFunction (MessageQueue.js:353)\n    at MessageQueue.js:118\n    at MessageQueue.__guardSafe (MessageQueue.js:316)\n\nThis is my axios call in my react native component:\n\n    componentDidMount() {\n        axios.get('mydomain.com/get/').then(response => {  // localhost:8000/get works\n            this.setState({foo:response.data});\n        }).catch(error => {\n            console.log(error);\n        });\n    }","ecosystem":"npm","package_name":"react-native","package_version":null,"solution":"It seems that unencrypted network requests are blocked by default in iOS, i.e. https will work, http will not.\n\nFrom the docs:\n\n  By default, iOS will block any request that's not encrypted using SSL.\n  If you need to fetch from a cleartext URL (one that begins with http)\n  you will first need to add an App Transport Security exception.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/49370747/network-error-with-axios-and-react-native","votes":47,"created_at":"2026-04-19T04:51:33.567053+00:00","updated_at":"2026-04-19T04:51:33.567053+00:00"}