본문 바로가기
콤퓨타/안드로이드

android emulator axios network error

by 다_녤 2025. 11. 9.
반응형

현상:

1. 로컬에서 docker 로 웹서버 띄운 후 에뮬레이터로 접속 시 안됨

2. 브라우저로 접속 시엔 됨

좌: 브라우저(접속됨) / 우: 에뮬레이터

 

원인:

1. 안드로이드 에뮬레이터의 localhost와 pc의 localhost가 정상적으로 연결 돼 있지 않음

2. stackoverflow에서 안드로이드 localhost가 별도로 정해져 있는 것을 알게 됨 (10.0.2.2 로 연결해야 됨)

https://stackoverflow.com/questions/5528850/how-do-you-connect-localhost-in-the-android-emulator

 

How do you connect localhost in the Android emulator?

I have made a php script inside localhost and I am connecting that with httpClient but I am getting a problem. Please tell me how can I connect to a php file at localhost from the emulator?

stackoverflow.com

 

3. 그 전엔 왜 localhost로 바로 맵핑이 됐는지 모르겠음

반응형