# Connection to GCS repository works in script, not from cron

**URL:** <https://kopia.discourse.group/t/connection-to-gcs-repository-works-in-script-not-from-cron/2151>\
**Category:** General Topics\
**Created:** [July 12, 2023, 7:58am UTC](https://kopia.discourse.group/t/connection-to-gcs-repository-works-in-script-not-from-cron/2151 "2023-07-12T07:58:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgw](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@sgw](https://kopia.discourse.group/u/sgw)\
**Post date:** [July 12, 2023, 7:58am UTC](https://kopia.discourse.group/t/connection-to-gcs-repository-works-in-script-not-from-cron/2151/1 "2023-07-12T07:58:02Z")

</div>

I built a shell-script (copy-paste-edit …) to sync a local sftp repository to a google cloud storage repository.

This shell script works when called from the shell (as root). When I call it from cron or a systemd-timer I get things like (anonymized quote):

```auto
ERROR can't connect to storage: unable to list from the bucket: ListBlobs: Get "https://storage.googleapis.com/storage/v1/b/somebucket/o?alt=json&delimiter=&endOffset=&includeTrailingDelimiter=false&pageToken=&prefix=kopia-gcs-storage-initializing-168914646xxxxxxx&prettyPrint=false&projection=full&startOffset=&versions=false": oauth2: cannot fetch token: Post "https://oauth2.googleapis.com/token": dial tcp 142.250.185.202:443: i/o timeout

```

The relevant part in the script:

```auto
$KOPIA repository sync-to gcs \
 --credentials-file "/root/somekey.json" \
 --bucket "somebucket" \
 --max-upload-speed=948576 \
 --no-delete \
 --no-update \
 --disable-color

```

As mentioned: it works on the shell. So I assume some environment variables might miss. While I type this I think of $http\_proxy etc … I will test in that direction.

---

<div class="post-metadata">

**Author:** ![sgw](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@sgw](https://kopia.discourse.group/u/sgw)\
**Post date:** [July 12, 2023, 8:27am UTC](https://kopia.discourse.group/t/connection-to-gcs-repository-works-in-script-not-from-cron/2151/2 "2023-07-12T08:27:21Z")

</div>

Yes, exporting the proxy-variables helps.
