GET Request from esp32 to local machine

Hello every one,

I’m trying to send a Get request from my ESP32 board to my local server in my machine.

I’m using Arduino IDE:

#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid = "XXXXX";
const char* pass = "XXXXX";

const char* host = "192.168.1.3"; // My local IP ADRESS

void setup() {
  Serial.begin(115200);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);
  Serial.println("Connecting");

  while(WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to WiFi network with IP Address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  if ((WiFi.status() == WL_CONNECTED)) { // Check the current connection status

    HTTPClient http;

    http.begin("http://192.168.1.3/esp32/save_data_GET.php?sensor1=100"); // Specify the URL
    int httpCode = http.GET(); // Make the request

    if (httpCode > 0) { //Check for the returning code

        String payload = http.getString();
        Serial.println(httpCode);
        Serial.println(payload);
      }

    else {
      Serial.println("Error on HTTP request");
      Serial.println(httpCode);

    }

    http.end(); //Free the resources
  }


  delay(5000);
}

I’m doing every thing by the book but i allway get: httpCode = -1 (

HTTPC_ERROR_CONNECTION_REFUSED)

The server is working fine on my local machine. 

Any ideia of what am I missing?
Thank you! :) 

I have the same problem, Did you find a solution?, Can you share it?, Please.

I had the same problem.

The issue turned out to be settings in the Wifi router.

On this particular router “Enable AP Isolation” was active. When this is activated, units on any SSID of this router are isolated from each other / cannot communicate, and my ESP32 and my http server were on the same SSID.

I have reserved this particular SSID for IoT devices, and my phone iPad etc were connected to other SSIDs - and could read devices on the IoT SSID without any issue. I confirmed the issue by connecting my phone to the IoT SSID and could no longer access the device with a http server.

Solution:
Deactivate “Enable AP Isolation” on the router 2,4 GHz wireless settings, like this:

Capture.JPG