Failed to configure token: failed to get token: lookup api.amazon.com: no such host

I’m having trouble setting up a remote. It seems my machine can’t resolve api.amazon.com even though I can ping it, and access it in my browser.

I have tried changing my DNS to various servers, like Google and OpenDNS. I have restarted my router and computer. I’ve tried reinstalling, installing from the directions on the website and using snaps. I can access https://api.amazon.com/auth/o2/token in my browser, I get <UnknownOperationException/> so it’s at least resolving.

Here is my log:
`2017/05/01 09:38:49 NOTICE: Config file “/home/aj/.config/rclone/rclone.conf” not found - using defaults
No remotes found - make a new one
n) New remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
n/r/c/s/q> n
name> acd
Type of storage to configure.
Choose a number from below, or type in your own value
[snip]
Storage> 1
Amazon Application Client Id - leave blank normally.
client_id>
Amazon Application Client Secret - leave blank normally.
client_secret>
Remote config
Use auto config?

  • Say Y if not sure
  • Say N if you are working on a remote or headless machine
    y) Yes
    n) No
    y/n> y
    If your browser doesn’t open automatically go to the following link: http://127.0.0.1:53682/auth
    Log in and authorize rclone for access
    Waiting for code…
    Got code
    2017/05/01 09:39:00 Failed to configure token: failed to get token: Post https://api.amazon.com/auth/o2/token: dial tcp: lookup api.amazon.com: no such host`

What else can I do?

This seems like it might be a Golang problem:

https://github.com/golang/go/issues/3575

https://github.com/moby/moby/issues/18842 [Docker is written in Golang]

I was able to fix the auth problem by adding 54.239.29.142 api.amazon.com to /etc/hosts.

However, now I run into the same problem for this:

rclone ls acd:/ 2017/05/01 10:06:39 Failed to create file system for "acd:/": failed to get endpoints: Get https://drive.amazonaws.com/drive/v1/account/endpoint: dial tcp: lookup drive.amazonaws.com: no such host

However, I can't use my /etc/hosts workaround for this, because I can't resolve drive.amazonaws.com to an IP: http://viewdns.info/reverseip/?host=drive.amazonaws.com&t=1

I think from before you were using Ubuntu.

can you ‘cat /etc/resolv.conf’ and see what’s listed there?

Yes, I am on Ubuntu.

aj@aj-UGnome ~ cat /etc/resolv.conf Generated by NetworkManager nameserver 127.0.1.1

In /etc/resolvconf/resolv.conf.d/base:
nameserver 8.8.8.8 nameserver 8.8.4.4

I use dnsleaktest.com to check my DNS and it is definitely Google.

What happens if you run:

dig api.amazon.com

dig api.amazon.com

; <<>> DiG 9.10.3-P4-Ubuntu <<>> api.amazon.com
;; global options: +cmd
;; connection timed out; no servers could be reached

Yeah, looks like your local DNS server isn’t running.

Just to test, you can manually edit your /etc/resolv.conf to match the previous post

/etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4

retest and run the dig and you should get a result back.

Test with your rclone and I would think that’ll work.

I replaced nameserver 127.0.1.1 with namerserver 8.8.8.8 and nameserver 8.8.4.4. Then I ran sudo service networking restart and sudo service network-manager restart.

I still get this:
rclone ls acd:/ 2017/05/01 12:53:56 Failed to create file system for "acd:/": failed to get endpoints: Get https://drive.amazonaws.com/drive/v1/account/endpoint: dial tcp: lookup drive.amazonaws.com: no such host

Don’t run a network restart, that’ll replace the file again and put it back to the old config.

You can just change the file and do the test :slight_smile:

It works! I had to disable network-manager so that it wouldn’t manage my DNS, and set DNS in /etc/network/interfaces. Now rclone works fine.

Thank you!!

1 Like

Awesome.

That was going to my next step but you already got there. Happy it works now.

1 Like

You can also add nameserver 8.8.8.8 to /etc/resolvconf/resolv.conf.d/head (assuming you are using a recent version of Ubuntu) to make it survive reboots, NetworkManager and other services that play with your DNS settings.