# Cannot connect to AWS IoT

**URL:** <https://forums.digi.com/t/cannot-connect-to-aws-iot/20048>\
**Category:** XBee Micropython & IDE plugin\
**Tags:** micropython, aws, iot\
**Created:** [November 26, 2018, 10:47am UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048 "2018-11-26T10:47:20Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![tylerkoldenjtp](https://avatars.discourse-cdn.com/v4/letter/t/2acd7d/32.png) [@tylerkoldenjtp](https://forums.digi.com/u/tylerkoldenjtp)\
**Post date:** [November 26, 2018, 10:47am UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/1 "2018-11-26T10:47:20Z")

</div>

I have followed the instructions for connecting a XBC LTE Cat 1 Verizon to AWS IoT as described here: [https://github.com/digidotcom/xbee-micropython/tree/master/samples/cellular/aws](https://github.com/digidotcom/xbee-micropython/tree/master/samples/cellular/aws)

The board I’m using is the Digi XBee Cellular LTE Cat 1 Development Kit, Verizon LTE Cat 1, USA ( [https://www.digi.com/products/models/xkc-v1t-u](https://www.digi.com/products/models/xkc-v1t-u) ). Verizon signal strength is 3 bars and I’ve successfully tested network connectivity with both the Echo server ( [https://www.digi.com/resources/documentation/Digidocs/90001541/tasks/t\_echo\_server.htm?TocPath=Getting%20started|\_\_\_\_\_10](https://www.digi.com/resources/documentation/Digidocs/90001541/tasks/t_echo_server.htm?TocPath=Getting%20started%7C_____10) ) and the Daytime server ( [https://www.digi.com/resources/documentation/Digidocs/90001541/tasks/t\_daytime\_server.htm?tocpath=Connection%20examples|\_\_\_\_\_3](https://www.digi.com/resources/documentation/Digidocs/90001541/tasks/t_daytime_server.htm?tocpath=Connection%20examples%7C_____3) )

I created a thing, attached a policy and downloaded / renamed the certificate files ( [https://www.digi.com/resources/documentation/digidocs/90002219/default.htm#tasks/t\_install\_certificates.htm%3FTocPath%3DUse%2520AWS%2520IoT%2520from%2520MicroPython|\_\_\_\_\_4](https://www.digi.com/resources/documentation/digidocs/90002219/default.htm#tasks/t_install_certificates.htm%3FTocPath%3DUse%2520AWS%2520IoT%2520from%2520MicroPython%7C _____ 4) ) except for the now legacy VeriSign public certificate.

Since my AWS IoT host includes the “-ats” in the hostname, I downloaded the Amazon Root CA1 (2048) from this location [https://www.amazontrust.com/repository/AmazonRootCA1.pem](https://www.amazontrust.com/repository/AmazonRootCA1.pem) and saved it as the aws.ca file.

When testing the certificates on a desktop with Python 3 ( [https://www.digi.com/resources/documentation/digidocs/90002219/default.htm#tasks/t\_test\_connection.htm%3FTocPath%3DUse%2520AWS%2520IoT%2520from%2520MicroPython|\_\_\_\_\_5](https://www.digi.com/resources/documentation/digidocs/90002219/default.htm#tasks/t_test_connection.htm%3FTocPath%3DUse%2520AWS%2520IoT%2520from%2520MicroPython%7C _____ 5) ), it connects successfully. I receive the expected output and it works great.

However, after I upload the three files (/flash/cert/aws.key, /flash/cert/aws.crt, /flash/cert/aws.ca) with the File system Manger tool, copy and paste the Micropython version of the “test connection” code with my parameters ( [https://www.digi.com/resources/documentation/digidocs/90002219/default.htm#tasks/t\_test\_connection.htm%3FTocPath%3DUse%2520AWS%2520IoT%2520from%2520MicroPython|\_\_\_\_\_5](https://www.digi.com/resources/documentation/digidocs/90002219/default.htm#tasks/t_test_connection.htm%3FTocPath%3DUse%2520AWS%2520IoT%2520from%2520MicroPython%7C _____ 5) ) and run with CTRL+D, I receive the following error:

Traceback (most recent call last):  
File “”, line 37, in  
File “”, line 24, in https\_test  
OSError: [Errno 7111] ECONNREFUSED

I’ve tested different file paths (relative “cert/aws.key” vs absolute “/flash/cert/aws.key”) without success. Uploading the key file through XCTU (securely as well as insecurely) didn’t change the error message received. The three files (aws.key, aws.crt, aws.ca) are the exact same ones that work successfully in Python3 using a Juypter Notebook.

The AWS IoT policy attached to the certificate is the most permissive.

Any help is greatly appreciated!

---

<div class="post-metadata">

**Author:** ![theguy159](https://avatars.discourse-cdn.com/v4/letter/t/f07891/32.png) [@theguy159](https://forums.digi.com/u/theguy159)\
**Post date:** [November 30, 2018, 4:05pm UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/2 "2018-11-30T16:05:50Z")

</div>

I have the same issue. I’m getting a slightly different error.  
Traceback (most recent call last):  
File “”, line 48, in  
File “”, line 36, in https\_test  
OSError: [Errno 7005] EIO

---

<div class="post-metadata">

**Author:** ![theguy159](https://avatars.discourse-cdn.com/v4/letter/t/f07891/32.png) [@theguy159](https://forums.digi.com/u/theguy159)\
**Post date:** [November 30, 2018, 4:05pm UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/3 "2018-11-30T16:05:53Z")

</div>

I got mine to work.  
I had to remove the -ats from the account name on the aws endpoint and use the legacy ca pem from symantec. Hope this helps.

---

<div class="post-metadata">

**Author:** ![DominusTemporis](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@DominusTemporis](https://forums.digi.com/u/DominusTemporis)\
**Post date:** [January 7, 2019, 9:11am UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/4 "2019-01-07T09:11:50Z")

</div>

Same problems here did you find a solution? is it related to -ats suffex?  
I got it to work once without -ats but only once.

---

<div class="post-metadata">

**Author:** ![theguy159](https://avatars.discourse-cdn.com/v4/letter/t/f07891/32.png) [@theguy159](https://forums.digi.com/u/theguy159)\
**Post date:** [January 7, 2019, 12:17pm UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/5 "2019-01-07T12:17:26Z")

</div>

Correct. You have to remove the -ats from the account name in the endpoint url. You also have to make sure that you use the legacy PEM from Symantec. I’ve been using it like this for about a month now. Make sure that if the device restarts, that you set up the profiles again for the socket. You don’t have to reimport the certs if you don’t want to.

---

<div class="post-metadata">

**Author:** ![petzincv](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@petzincv](https://forums.digi.com/u/petzincv)\
**Post date:** [May 8, 2024, 9:17pm UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/6 "2024-05-08T21:17:35Z")

</div>

I have a XBee 3 cellular (LTE-M) and I am having this exact problem. The XBee device was running fine and sending data to AWS using the downloaded Amazon Root CA1 and other certificate files for the past week. Today I have suddenly started getting the OSError: [Errno 7111] ECONNREFUSED on MQTT connect. I have tried creating a new thing and downloading new certificates but I am still having the same issue. Does anyone know if there is a quota or other AWS setting that could cause this to suddenly be an issue?

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [May 9, 2024, 12:14pm UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/7 "2024-05-09T12:14:55Z")

</div>

> [@petzincv](#):
>
> OSError: [Errno 7111]

Try restarting the radio using the ATSD1 command.

---

<div class="post-metadata">

**Author:** ![petzincv](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@petzincv](https://forums.digi.com/u/petzincv)\
**Post date:** [May 10, 2024, 12:53pm UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/9 "2024-05-10T12:53:35Z")

</div>

Thanks for the replies. I have found that if I swap SIM cards I can get a successful connection for a while but the problem seems to just come back after a while. I have another device that is consistently writing to our endpoint with without issue. How do you send a " ATSD1 command". I can not find any documentation on it.

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [May 10, 2024, 1:07pm UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/10 "2024-05-10T13:07:15Z")

</div>

[https://www.digi.com/resources/documentation/digidocs/90002253/default.htm#reference/r\_cmd\_sd.htm?Highlight=SD](https://www.digi.com/resources/documentation/digidocs/90002253/default.htm#reference/r_cmd_sd.htm?Highlight=SD)

[https://www.digi.com/resources/documentation/digidocs/90002253/default.htm#tasks/t\_send\_commands.htm?Highlight=AT%20commands](https://www.digi.com/resources/documentation/digidocs/90002253/default.htm#tasks/t_send_commands.htm?Highlight=AT%20commands)

---

<div class="post-metadata">

**Author:** ![petzincv](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@petzincv](https://forums.digi.com/u/petzincv)\
**Post date:** [May 10, 2024, 3:08pm UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/11 "2024-05-10T15:08:29Z")

</div>

After more testing, I have found If I swap sim cards my Xbee3 I can connect and continuously write to AWS. If I then restart the device my connections are then refused [Errno 7111] ECONNREFUSED. Using the shutdown command before restarting does not appear to fix this issue. I have observed this behavior with two different Xbee device that set up as different AWS “Things”. I am using Hologram sim cards.

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [May 10, 2024, 6:23pm UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/12 "2024-05-10T18:23:32Z")

</div>

This is sounding like you may have a socket that is stuck open on the server or within the carrier. Are you using the Close socket functions at all? If not, you should.

Which radio is this on? What firmware version are you running?

What are you placing in for the APN? Is it the APN that the carrier desires or is it the default connection APN?

---

<div class="post-metadata">

**Author:** ![petzincv](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@petzincv](https://forums.digi.com/u/petzincv)\
**Post date:** [May 16, 2024, 1:28pm UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/13 "2024-05-16T13:28:01Z")

</div>

I am using firmware 1161C on XCB Global LTE-M radio. I am using a hologram card my APN is “hologram”. It is connecting to a T-Moble network. I am able to establish a cell connection fine.

Is there a setting or something else that is reset when a new sim card is used vs just shutting down the radio and restarting the device?

To test the connection I am using the basic umqtt.simple library.

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [May 16, 2024, 5:40pm UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/14 "2024-05-16T17:40:47Z")

</div>

That would depend on the Carrier. At minimum you would need to change the APN value. You may also need to change the CP value.

---

<div class="post-metadata">

**Author:** ![davidmark](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@davidmark](https://forums.digi.com/u/davidmark)\
**Post date:** [July 22, 2024, 12:51pm UTC](https://forums.digi.com/t/cannot-connect-to-aws-iot/20048/15 "2024-07-22T12:51:49Z")

</div>

It sounds like you’ve taken the correct steps, but the ECONNREFUSED error usually means the connection to the server is being refused. Please double-check that the AWS IoT endpoint hostname is correct and includes `-ats`, verify the file paths in your MicroPython code, and ensure the Digi XBee has internet access. Confirm that the AWS IoT policy allows `iot:Connect`, `iot:Publish`, `iot:Subscribe`, and `iot:Receive`, and that the port used (usually 8883 for MQTT over TLS) is correct. Also, ensure there are no firewall rules blocking the connection. If the issue persists, enabling detailed logging on the AWS IoT side may provide more insights.
