Flutter

[Flutter]SocketException: Connection refused

코린이탈출기 2024. 3. 23. 19:31
728x90

 

 


Flutter에서 API 통신 에러 SocketException 중 ip 주소 에러에 대해 정리해 보았다.

 

I/flutter ( 6681): Error: SocketException: 
Connection refused (OS Error: Connection refused, errno = 111),
address = localhost, port = 39968

 

 

어떤 기기로 실행하느냐에 따라 IP 주소를 달리 해줘야 한다.

 

1. Android Emulator

 

http://10.0.2.2:8080/test

 

 

2. iOS Simulator

 

http://127.0.0.1:8080/test

 

 

3. 내 휴대폰에서 직접 실행

 

터미널에서 자신의 IP 주소 확인

 

// mac OS
ifconfig

// window
ipconfig

 

맥에서 ifconfig 명령어를 입력했다면 en0 또는 en1 중에 활성화된 네트워크 인터페이스의 IP주소를 확인한다.

보통 Wi-Fi는 en0이며, 이더넷은 en1이다.

 

 

http://${자신의 ip 주소}:8080/test

 

 

 

 

728x90