# API connection via ipv6 vs. ipv4

**URL:** https://meta.discourse.org/t/api-connection-via-ipv6-vs-ipv4/155024
**Category:** Development
**Tags:** rest-api
**Created:** [June 16, 2020, 4:18pm UTC](https://meta.discourse.org/t/api-connection-via-ipv6-vs-ipv4/155024 "2020-06-16T16:18:20Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![bhuang61\_gmail.com](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bhuang61_gmail.com/32/184176_2.png) [@bhuang61\_gmail.com](https://meta.discourse.org/u/bhuang61_gmail.com)
#### Post date: [June 16, 2020, 4:18pm UTC](https://meta.discourse.org/t/api-connection-via-ipv6-vs-ipv4/155024/1 "2020-06-16T16:18:20Z")

</div>

Hi all,

I have a problem with accessing the API in a timely manner. I’m accessing the following URL:  
[https://community.tenxguitar.com/c/7.json](https://community.tenxguitar.com/c/7.json)

I’ve created an API key and a user and all seems good so far.

When I test it from Postman with the proper credentials it returns immediately with data as I would expect.

The problem comes in when I try to access it from someplace besides Postman…like my code. It takes MINUTES to return, but it does eventually return with data.

Same problem from a terminal with this:

```
wget --no-check-certificate --quiet \
  --method GET \
  --timeout=0 \
  --header 'Api-Key: correct-api-key-here' \
  --header 'Api-Username: <correct user name here>' \
   'https://community.tenxguitar.com/c/7.json'

```

Same behavior as my python code. I don’t believe I have any configuration settings that would affect this (on the forum). Can anyone please advise or help me?

Thanks!

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [June 16, 2020, 4:55pm UTC](https://meta.discourse.org/t/api-connection-via-ipv6-vs-ipv4/155024/2 "2020-06-16T16:55:32Z")

</div>

Is Postman, and your example command-line code, both being run from the same machine?

Tried curl for a third comparison, rather than wget?

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [June 16, 2020, 7:33pm UTC](https://meta.discourse.org/t/api-connection-via-ipv6-vs-ipv4/155024/3 "2020-06-16T19:33:08Z")

</div>

> [@bhuang61\_gmail.com](#):
>
> It takes MINUTES to return, but it does eventually return with data.

Does it return the results immediately if you add the `-4` option to wget?

If not, can you post the (redacted) output if you add the `-v` option?

---

<div class="post-metadata">

### Author: ![bhuang61\_gmail.com](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bhuang61_gmail.com/32/184176_2.png) [@bhuang61\_gmail.com](https://meta.discourse.org/u/bhuang61_gmail.com)
#### Post date: [June 16, 2020, 7:53pm UTC](https://meta.discourse.org/t/api-connection-via-ipv6-vs-ipv4/155024/4 "2020-06-16T19:53:28Z")

</div>

Yes, it’s on the same machine.

---

<div class="post-metadata">

### Author: ![bhuang61\_gmail.com](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bhuang61_gmail.com/32/184176_2.png) [@bhuang61\_gmail.com](https://meta.discourse.org/u/bhuang61_gmail.com)
#### Post date: [June 16, 2020, 8:06pm UTC](https://meta.discourse.org/t/api-connection-via-ipv6-vs-ipv4/155024/5 "2020-06-16T20:06:34Z")

</div>

Michael,

I tried the -4 option (which I’m unfamiliar with) and it worked immediately and as expected. I then tried the -v option and if I read correctly, it looks like an SSL timeout. Here’s the -v output. Can you elaborate on the -4 option? Thanks! Note I had to cut some stuff out due to posting restrictions on links.

Resolving [community.tenxguitar.com](http://community.tenxguitar.com) ([community.tenxguitar.com](http://community.tenxguitar.com))… 2001:470:1:59e::139, 66.220.12.139  
Connecting to   
()|2001:470:1:59e::139|:443… failed: Connection timed out.  
Connecting to ()|66.220.12.139|:443… connected.  
HTTP request sent, awaiting response… 200 OK  
Length: unspecified [application/json]  
Saving to: ‘7.json.4’

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [June 16, 2020, 8:12pm UTC](https://meta.discourse.org/t/api-connection-via-ipv6-vs-ipv4/155024/6 "2020-06-16T20:12:02Z")

</div>

> [@bhuang61\_gmail.com](#):
>
> I tried the -4 option (which I’m unfamiliar with) and it worked immediately and as expected.

> [@bhuang61\_gmail.com](#):
>
> Connecting to 2001:470:1:59e::139:443… failed: Connection timed out.

Your machine currently has both IPv4 and IPv6 address configured, but your IPv6 connectivity is broken and connection attempts via IPv6 time out.

wget (and probably your Python code) is trying IPv6 first, timing out, then connecting successfully over IPv4. But it works when `-4` forces the use of IPv4.

postman is likely either only using IPv4, or it is [trying both IPv4 and IPv6 at the same time and using whichever connects first](https://en.wikipedia.org/wiki/Happy_Eyeballs).

You’ll need to investigate why IPv6 connections don’t work on your network. Even if they fail immediately, that’s better since wget will know to immediately try via IPv4 rather than wait for IPv6.

(or, force your connections to IPv4-only)

---

<div class="post-metadata">

### Author: ![bhuang61\_gmail.com](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bhuang61_gmail.com/32/184176_2.png) [@bhuang61\_gmail.com](https://meta.discourse.org/u/bhuang61_gmail.com)
#### Post date: [June 18, 2020, 3:40pm UTC](https://meta.discourse.org/t/api-connection-via-ipv6-vs-ipv4/155024/7 "2020-06-18T15:40:35Z")

</div>

Thank you sir! That is interesting. I’ll look into it. Thanks again.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [July 18, 2020, 3:47pm UTC](https://meta.discourse.org/t/api-connection-via-ipv6-vs-ipv4/155024/8 "2020-07-18T15:47:47Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
