After assigning static IP to my ESP32 server doesn't respond anymore

So I've got ESP32 acting as a server, and when calling http://IP_OF_ESP32:7777/SOMETEXT my code enables me to view the text written after the slash, the problem is that after assigning static IP to my ESP32 it doesn't work anymore here's my code

#include <WiFi.h>

const char* ssid = "Inovec1";
const char* password =  "ccb255fd8f52";

WiFiServer server(7777);

IPAddress local_IP(192, 168, 121, 100);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);
IPAddress primaryDNS(8, 8, 8, 8);
IPAddress secondaryDNS(8, 8, 4, 4);

void setup() {
  Serial.begin(115200);
  WiFi.config(local_IP,gateway,subnet,primaryDNS, secondaryDNS);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(100);
    Serial.print(".");
  }
  Serial.println(WiFi.localIP());
  server.begin();
}
 
void loop() {
  WiFiClient client = server.available();
  String message;
  while(client.available()){
    char c = client.read();
    message += c;
  }
  String command = getCommand(message);
  if(command.length()>0)
    Serial.println(command);
}

String getCommand(String s){
  String toFind1 = "GET /";
  String toFind2 = " HTTP";
  int start = s.indexOf(toFind1)+toFind1.length(); 
  int end = s.indexOf(toFind2); 
  return s.substring(start,end);
}

Are you sure those values are correct?

IPAddress local_IP(192, 168, 121, 100);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);

Most home routers define a class C network (netmask 255.255.255.0), I have never seen one that defines a class B network (netmask 255.255.0.0) as you defined it. Where are these values from? Is your router configured that way?

pylon:
Are you sure those values are correct?

IPAddress local_IP(192, 168, 121, 100);

IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);




Most home routers define a class C network (netmask 255.255.255.0), I have never seen one that defines a class B network (netmask 255.255.0.0) as you defined it. Where are these values from? Is your router configured that way?

My PC
Well then I guess that's the problem ..
IPv4 192.168.0.101
Subnet Mask 255.255.255.0
Def. Gateway 192.168.0.1

Router : 192.168.0.1
How should I change the code if I may ask?

I wrote a long post to explain this, but the forum decided it was time for me to authenticate when I tried to post and threw it away.

Synopsis: use the same subnet mask as your PC and try 192.168.0.170 for your IP. Ping it first to ensure it's free.

IPAddress local_IP(192, 168, 0, 170);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress primaryDNS(8, 8, 8, 8);
IPAddress secondaryDNS(8, 8, 4, 4);

Works just fine, but could you explain to me at least briefly why local_IP(192, 168, 1, 121) doesn't work anymore ?

Pylon gave you the important clue, your router is managing a C class network. Which means that the first three bytes of the address define the network and the last byte identifies a node on that network. That's what the subnet mask is telling you, albeit obliquely.

So, every IP address on your network must start with the same three bytes: 192.168.0 in your case. 192.168.1.121 doesn't match, so it doesn't work.

Just a side question, what wifi library do you use with your ESP32 board? The wifi boards have been developed since I've been playing around with the Arduino boards. I loaded your code on the latest Arduino IDE and there was a compile error, probably due to not having a correct wifi library, or some other basic issue. The ESP32 sounds interesting and I may put one on the Santa Clause list.

I loaded your code on the latest Arduino IDE and there was a compile error, probably due to not having a correct wifi library, or some other basic issue.

Did you choose the ESP32 as the target board? That code won't compile for an Arduino UNO! Did you install the ESP32 core?