I'm trying to connect my nodeMCU to my WiFi network but it keeps printing ........ which means is not connecting to the network. Here is my code used to connect to WiFi. Any reason why it isn't connecting to WiFi network?.

#include <ESP8266WiFi.h>

        // Replace these with your WiFi network settings
        const char* ssid = "******"; //replace this with your WiFi network name
        const char* password = "******"; //replace this with your WiFi network password

        void setup()

          WiFi.begin(ssid, password);

          while (WiFi.status() != WL_CONNECTED)

          Serial.print("IP Address is: ");

        void loop() {
  • could be that your router is refusing the connection
    – jsotola
    Nov 3, 2018 at 18:19
  • @jsotola how to fix it?
    – TRomesh
    Nov 3, 2018 at 18:19
  • 1
    that is only a guess ..... there could be other reasons ...... try connecting to another network ..... maybe one that does not require a password
    – jsotola
    Nov 3, 2018 at 18:26
  • try WiFiScan example
    – Juraj
    Nov 3, 2018 at 18:28
  • 1
    including the SSID you want to connect?
    – Juraj
    Nov 3, 2018 at 18:34

2 Answers 2


If your WiFi network doesn't have DHCP, then you must set the IP addresses


  IPAddress ip(192, 168, 1, 8);
  IPAddress gw(192, 168, 1, 1);
  IPAddress sn(255, 255, 255, 0);
  WiFi.config(ip, gw, sn, gw);

gw is gateway. the last parmeter is dns server's IP. sn is subnet mask.

  • Thanks for the answer but i checked my router configs and its is DHCP enabled
    – TRomesh
    Nov 3, 2018 at 18:59
  • see DHCP logs in router if there is a record about DHCP request from the esp
    – Juraj
    Nov 3, 2018 at 19:01

If your powering the device via a computer USB port there is a good chance it’s not providing enough power for the wifi. Try powering fron an external source.

  • 1
    where did you get this? 500 mA from USB is enough. he has no motor connected
    – Juraj
    Nov 4, 2018 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.