Sending Image over HTTP not working

I have hosted a server and am trying to send an image to it. It works fine in Postman; however, when trying with the amb-82 mini, these are the logs.

AP IP address: Capturing and sending image to API
Capturing image…
Image captured. Address: 70DE6880, Length: 83083
[INFO] Create socket successfully
[ERROR] start_client Connect to server failed
Status code: -3
Image sending process completed
192.168.1.1

Here is the code to it

void sendImageToAPI(uint8_t* img_addr, uint32_t img_len) {
    WiFiClient wifi;
    HttpClient client(wifi);

    String boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW";
    String contentType = "multipart/form-data; boundary=" + boundary;

    int err = client.post(api_server_ip, server_port, "/upload");
    if (err != 0) {
        Serial.print("Connect failed: ");
        Serial.println(err);
        return;
    }

client.sendHeader("Content-Type", contentType.c_str());
    unsigned long contentLength = 
        String("--" + boundary + "\r\n").length() +
        String("Content-Disposition: form-data; name=\"file\"; filename=\"image.jpg\"\r\n").length() +
        String("Content-Type: image/jpeg\r\n\r\n").length() +
        img_len +
        String("\r\n--" + boundary + "--\r\n").length();
    
    client.sendHeader("Content-Length", String(contentLength).c_str());

    client.println("--" + boundary);
    client.println("Content-Disposition: form-data; name=\"file\";filename=\"image.jpg\"");
    client.println("Content-Type: image/jpeg");
    client.println();

    // Send the image data
    client.write(img_addr, img_len);

    client.println();
    client.println("--" + boundary + "--");

    int statusCode = client.responseStatusCode();

    Serial.print("Status code: ");
    Serial.println(statusCode);
}

void captureAndSendImageToAPI() {
    Serial.println("Capturing and sending image to API");
    
    Serial.println("Capturing image...");
    Camera.getImage(CHANNEL, &img_addr, &img_len);
    Serial.print("Image captured. Address: ");
    Serial.print((unsigned long)img_addr, HEX);
    Serial.print(", Length: ");
    Serial.println(img_len);
    
    sendImageToAPI((uint8_t*)img_addr, img_len);
    Serial.println("Image sending process completed");
}


if(deviceConnected && connectedReceived){

      Serial.println("Inside connected");
        IPAddress apIP = WiFi.localIP();
        Serial.print("AP IP address: ");
        //sendImageToFlutterAppViaUDP();
        captureAndSendImageToAPI();

        Serial.println(apIP);
        delay(3000);  // Wait 3 seconds        
        
        connectedReceived = false;
    }


Note: This thing behaved weirdly yesterday. It worked for an hour or so then it didn’t

Hi @Jash_Doshi,

May I know what server are you using?

[ERROR] start_client Connect to server failed. This shows that the communication between AMB82 mini and your server is not established. Is your server on?

I have sent post request from ameba client to nextJS app before.

Thank you.