Arduino UNO stuck in Setup function when interfacing UNO with ESP8266 module
It's always a good idea to put a serial output in the setup of your code.


It seems that your Arduino resets itself.

But why?

I believe the problem would be with too little power for your ESP8266 and Arduino. When the ESP8266 wants to create a network connection, it takes a little more current, possibly leaving your Arduino without enough current to run on itself.

So your Arduino would shut down since the ESP8266 takes up all the current. Creating some kind of bootloop on your Arduino.

Please tell us how you powered the devices and how you connected them.
You might try using a separate power supply or a big capacitor on the Arduino's 5V+GND.