GuzzleHttp \ Exception \ ConnectException cURL error 7: Failed to connect to localhost port 8088: Connection refused
Asked Answered
S

3

5

I'm using laradock and I can access the page in browser http://localhost:8088/api/getakicks/get without any problems.

But when I try to access it in controller I'm getting this error:

GuzzleHttp \ Exception \ ConnectException cURL error 7: Failed to connect to localhost port 8088: Connection refused

The code I use:

  $client = new \GuzzleHttp\Client();

  // Set various headers on a request
  $client->request('GET', 'http://localhost:8088/api/getakicks/get');
Silma answered 14/9, 2018 at 8:37 Comment(0)
S
9

Get IP address on MAC, click on wifi icon -> Open Network Preferences -> then copy the IP address 192.168.100.41 (own unique IP) and replace with xxx in below code

$client->request('GET', 'http://xxx.xxx.xx.x:8088/api/getakicks/get');
Streptococcus answered 3/2, 2021 at 11:6 Comment(1)
yes I did change it and it is working well.Knapweed
D
1

changed the IP address from localhost:8088 to windows IP address 192.168.x.x:8088.

Dapple answered 14/9, 2018 at 8:42 Comment(3)
Thank you for your comment. Now I get cURL error 6: Could not resolve host: 118.238.x.x I'm on MacSilma
Replace x with number, for example 192.168.1.24Scoggins
@RouhollahMazarei I did in the first place - just didn't wanna flash my IP out :)Silma
G
0

When using Docker, localhost in the container points to the container itself, not your host machine. In your case changing http://localhost:8088 to http://host.docker.internal:8088 lets the container access services on your host’s localhost, which fixes the connection issue.

Glutathione answered 6/11 at 12:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.