Go Down

Topic: Arduino.cc Wifi Shield Connection Refused (Read 6783 times) previous topic - next topic


I'm using the example code and get a ping response from the IP it connects to, but serving from and telnet to a variety of ports always fails with Connection Refused on two different networks. Anyone have a clue?

Code: [Select]

#include <SPI.h>
#include <WiFi.h>

char ssid[] = "ckp";      // your network SSID (name)
char pass[] = "password";   // your network password
int keyIndex = 0;                 // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(23);

void setup() {
  //Initialize serial and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:   
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
  // you're connected now, so print out the status:

void loop() {
  // listen for incoming clients
  WiFiClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println("<!DOCTYPE HTML>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(" is ");
            client.println("<br />");       
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
    // give the web browser time to receive the data
    // close the connection:
    Serial.println("client disonnected");

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.println(" dBm");

Serial output:

Code: [Select]

Attempting to connect to SSID: ckp
SSID: ckp
IP Address:
signal strength (RSSI):-65 dBm


Code: [Select]

CK:arduino etw$ ping
PING ( 56 data bytes
64 bytes from icmp_seq=0 ttl=255 time=46.712 ms
64 bytes from icmp_seq=1 ttl=255 time=3.614 ms
64 bytes from icmp_seq=2 ttl=255 time=3.679 ms


Code: [Select]

CK:arduino etw$ telnet 23
telnet: connect to address Connection refused
telnet: Unable to connect to remote host


Also, no result from port scan:

Code: [Select]

CK:arduino etw$ /Applications/Utilities/Network\ Utility.app/Contents/Resources/stroke 0 1000
Port Scanning host:


I was having this problem with Arduino IDE 1.0.5. I noticed that going back to 1.0.3 works. Looks like something is bad between 1.0.5 and wifi shield.


The signal level  at -65dbm is not great.

Check you do not have a firewall running on the host you are trying to connect from.
The error message indicates the connection attempt is being refused (actively), rather than timing out.


Jun 15, 2013, 01:14 pm Last Edit: Jun 15, 2013, 01:55 pm by SurferTim Reason: 1
I don't agree with this. That isn't bad at all.
The signal level  at -65dbm is not great.

I do agree with this.
The error message indicates the connection attempt is being refused (actively), rather than timing out.

Are you sure there is not another device responding to the pings? That "connection refused" is a firewall response, and the w5100 has no firewall, (edit:) and I presume the wifi shield has no firewall either. Disconnect the Arduino from your localnet and try the ping again.

BTW, my routers do a similar check when assigning localnet ips with dhcp. They do a ping to the ip about to be assigned to a new client, and if a device responds within a half second, it marks that ip lease as "busy", and gets another free ip from the ip pool.

edit: I use PuTTY in RAW mode to test http connections.


I was having this problem with Arduino IDE 1.0.5. I noticed that going back to 1.0.3 works. Looks like something is bad between 1.0.5 and wifi shield.

THANK YOU! You just saved me.
Indeed, I confirm that the WiFi shield that refused to work corectly since I bought it last thursday (and I paid a hundred of Euros for it!) now works like a charm since I've downgraded the IDE from version 1.0.5 to 1.0.3.

Thank you @marcelrocks, you definitely rock!!! :)


Same problem here. Frustrating - I wasted many hours on trying to get the Wifi Shield working with 1.0.5. After going back to Arduino 1.0.3 it all worked fine. Thanks for posting a temporary fix to this problem!


I have the same problem,
I have downgraded to 1.0.3 but still get the same error.
can someone help?


Actually, I think the subject line should be "I refuse to do the wifi shield firmware upgrade, and now it doesn't work".

@Sagiv: Post the code you are trying, and also include the security type (open, WEP, WPA, WPA2) that your router uses. Don't include the password tho.



I had the same problem. I did the firmware upgrade but was still having problems connecting. When I migrated to the 1.0.3 IDE, I was able to connect to the Arduino using Tera Term. Thank you very much for the fix!

While I am able to connect, however, I am having an issue with the echo. What I type in the terminal emulator appear in the IDE Serial Monitor but does not echo back. Has anyone had this problem? I could really use some advice.

Thanks again,
Yusif Nurizade



Dear ALL!! Wuuuuussssuuuuuuppppp ??

Saw this sulotion in many cases over the web, I have upgraded IDE to 1.6.3, Can any one confirm 1.6.3 also solve wifi shield responding issue ?

I'm working with Arduino Mega and Wifi Shield.

SSID & Pass ? Geezz thanks ! lol  :smiley-yell:


Apr 18, 2015, 08:15 am Last Edit: Apr 18, 2015, 08:23 am by SurferTim
@henp: Only if you have done the upgrade and confirmed you have firmware v1.1.0 on the wifi shield.

And FYI, if you do the upgrade as some above claimed to have done, the wifi libraries prior to v1.0.4 will no longer work. So any user who posted above that they downgraded to IDE v1.0.3 and the wifi worked did not complete the upgrade.

Go Up