question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`socket.timeout: timed out` when using full IPv6 stack.

See original GitHub issue

Environment details

  • OS: macOS 10.14.5 (18F132) Mojave
  • Python version: 3.7.3
  • pip version: 19.1.1
  • google-api-python-client version: 1.7.9

Steps to reproduce

Pre-steps:

  • Have a full IPv6 stack with an IPv6 address. In my case, I have the following from Spectrum, through a Linksys WRT3200ACM router.
inet6 fe80::4ab:197d:b439:8d97%en0 prefixlen 64 secured scopeid 0x9 
inet6 2604:6000:1013:a0eb:cca:87bb:d7ed:91b6 prefixlen 64 autoconf secured 
inet6 2604:6000:1013:a0eb:91e1:1128:7728:8e1 prefixlen 64 autoconf temporary 

Error:

  1. Follow the steps for the Python Quickstart (https://developers.google.com/docs/api/quickstart/python)
  2. run python quickstart.py
  3. python exits with socket.timeout: timed out error

If I open System Preferences > Network > Wi-FI > Advanced > TCP/IP and change the IPv6 configuration from Automatically to Link-local only, the quickstart.py properly runs.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:34 (15 by maintainers)

github_iconTop GitHub Comments

7reactions
gselvacommented, Jun 2, 2020

@vladignatyev - I had this error and was able to get around it by updating /etc/gai.conf to prefer IPV4 over IPV6 (uncomment the line precedence ::ffff:0:0/96 100 ).

5reactions
clmcavaneycommented, Jun 4, 2021

Had the same issue. I can see from a nmap that TCP ports 80 and 443 are not open on the IPv6 addresses for www.googleapis.com but they are open for IPv4 addresses:

$ nmap -Pn -p80,443 -6 www.googleapis.com

Starting Nmap 7.60 ( https://nmap.org ) at 2021-06-04 17:57 AEST
Nmap scan report for www.googleapis.com (2404:6800:4015:802::200a)
Host is up.
Other addresses for www.googleapis.com (not scanned): 2404:6800:4015:801::200a 2404:6800:4015:800::200a 2404:6800:4015:803::200a 142.250.70.234 142.250.70.170 142.250.70.138 142.250.70.202
rDNS record for 2404:6800:4015:802::200a: mel05s01-in-x0a.1e100.net

PORT    STATE    SERVICE
80/tcp  filtered http
443/tcp filtered https

Nmap done: 1 IP address (1 host up) scanned in 3.07 seconds
$ nmap -4 www.googleapis.com

Starting Nmap 7.60 ( https://nmap.org ) at 2021-06-04 17:56 AEST
Nmap scan report for www.googleapis.com (142.250.70.202)
Host is up (0.034s latency).
Other addresses for www.googleapis.com (not scanned): 2404:6800:4015:802::200a 2404:6800:4015:803::200a 2404:6800:4015:800::200a 2404:6800:4015:801::200a 142.250.70.234 142.250.70.138 142.250.70.170
rDNS record for 142.250.70.202: mel05s01-in-f10.1e100.net
Not shown: 998 filtered ports
PORT    STATE SERVICE
80/tcp  open  http
443/tcp open  https

Nmap done: 1 IP address (1 host up) scanned in 5.16 seconds

I used the quick hack from here in my code to force the underlying socket to connect over IPv4: https://stackoverflow.com/a/50044152

It looks like a Google firewall issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

python socket.connect -> timed out why? - Stack Overflow
From port 21 I assume it's an FTP port you're trying to open. Have you tried to connect using an FTP client to...
Read more >
IPv6 connections timeout - Unix & Linux Stack Exchange
From your updated question, I can see that when Networkmanager sends out router solicitation, the router immediately responds with router ...
Read more >
Is there any setting for connection timeout when IPv6 fallback ...
Hi,. 21 seconds is basically the max that any given HTTP connect can take. It's not IPv6 problem. Therefore, there is no specific...
Read more >
11 Ways to Fix the ERR_CONNECTION_TIMED_OUT Error
The connection timed out error isn't a dangerous error, ... reach the user before the countdown expires, the Err connection timeout happens.
Read more >
networking - ssh ipv6 - Connection timed out - Ask Ubuntu
I recently ran into this error and determined that by placing an IPv6 address within brackets causes ssh to interpret the IPv6 address...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found