# Sync / Share Google Calendar & Nextcloud Calendar

**URL:** <https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131>\
**Category:** ℹ️ Support\
**Tags:** calendar-app\
**Created:** [April 18, 2021, 8:38pm UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131 "2021-04-18T20:38:11Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicooo](https://help.nextcloud.com/letter_avatar/nicooo/32/6_22734026db12803ebb3e059622ac3534.png) [@nicooo](https://help.nextcloud.com/u/nicooo)\
**Post date:** [April 18, 2021, 8:38pm UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/1 "2021-04-18T20:38:11Z")

</div>

Hi,

Just sharing something i found useful.

**context :** i am using nextcloud calendar, my wife is still using google calendar. i want to see her calendar (read only) in nextcloud and she wants to see mine (read only) in google.

**easiest solution :** get her to use your nextcloud server’s calendar !!! 🙂

if for some reason, she does not want to, keep reading.

**sharing a google calendar in nextcloud :**

- connect to the google calendar to be shared
- click on the dented wheel on the top right, to open settings
- on the nav bar on the left, scroll down to “settings for my calendars”, then develope menu for the calendar to be shared
- scroll down to “integrate calendar”
- look for "secret address in ical format and click on “copy” icon
- head back to nextcloud calendar app
- click on the plus sign next to “new calendar” on the left nav bar
- then click on "new subscription from lin (read only)
- copy paste the link from google calendar, then validate
- after a few seconds, events from the google calendar should show up
- profit !

**sharing a nextcloud calendar in google :**  
you could use the subscription link from nextcloud and add it to your google calendar… but as google only refreshes external calendar not so frequently (like every 24 hours), this is not really a satisfying solution.  
after a long time googling for a solution i found this : [GitHub - derekantrican/GAS-ICS-Sync: A Google Apps Script for syncing ICS/ICAL files faster than the current Google Calendar speed](https://github.com/derekantrican/GAS-ICS-Sync)  
as explained in the read me :

- copy paste this script to your own google app script interface
- edit the script and modify some values :
- line 21 paste the subscription link from your nextcloud calendar and choose the calendar name that will appear in google calendar
- lines 24 to 39 review options and modify as needed (especially refresh interval, by default : 15 min)
- on the top menu select “install” function", then click on “run”
- on the top menu select “startSync” function, then click on “run”
- you will need to grant permissions for this script to edit your calendar
- after a few seconds events form your nextcloud calendar should show up on your google calendar

**nb :** obvisouly you have to make sure google can access your nextcloud instance. for example, i had set uo cloudflare in front of my instance to block connections from other countries than mine. i had to add a rule allowing google AS before the rule blocking all countries but mine.

---

<div class="post-metadata">

**Author:** ![Gorom](https://help.nextcloud.com/letter_avatar/gorom/32/6_22734026db12803ebb3e059622ac3534.png) [@Gorom](https://help.nextcloud.com/u/Gorom)\
**Post date:** [October 19, 2021, 11:34am UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/2 "2021-10-19T11:34:43Z")

</div>

Thanks a lot for this helpful thread !

---

<div class="post-metadata">

**Author:** ![muck](https://help.nextcloud.com/letter_avatar/muck/32/6_22734026db12803ebb3e059622ac3534.png) [@muck](https://help.nextcloud.com/u/muck)\
**Post date:** [February 4, 2022, 1:53pm UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/3 "2022-02-04T13:53:08Z")

</div>

Sadly, it doesn’t seem to work for me. After roughly 24 hours, changes I made in gcal are not synced to nextcloud-calendar. This seems to import gcal, but no sync. Any advice?

best regards

---

<div class="post-metadata">

**Author:** ![tcit](https://help.nextcloud.com/user_avatar/help.nextcloud.com/tcit/32/5931_2.png) [@tcit](https://help.nextcloud.com/u/tcit)\
**Post date:** [February 8, 2022, 1:34pm UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/4 "2022-02-08T13:34:43Z")

</div>

> [@muck](#):
>
> After roughly 24 hours, changes I made in gcal are not synced to nextcloud-calendar. This seems to import gcal, but no sync. Any advice?

Default subscription refresh rate is of one week.  
[https://docs.nextcloud.com/server/latest/admin\_manual/groupware/calendar.html#subscriptions](https://docs.nextcloud.com/server/latest/admin_manual/groupware/calendar.html#subscriptions)

---

<div class="post-metadata">

**Author:** ![florom](https://help.nextcloud.com/letter_avatar/florom/32/6_22734026db12803ebb3e059622ac3534.png) [@florom](https://help.nextcloud.com/u/florom)\
**Post date:** [February 8, 2022, 3:46pm UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/5 "2022-02-08T15:46:06Z")

</div>

Hi all,

@nicooo @Gorom @muck @tcit  
be aware that sharing like this does not include encryption nor authentication.  
So you basically share plain text the calendars (nextcloud and google) to everyone who got the link somehow and every knot on the internet can read it too.  
It is meant for public calendars (like concert events).

A secure solution is to make a google / apple account and use for example outlook and caldav to sync between the instances. This is not a superb solution but the only I am aware of which offers security and authentication. If anyone is interested in a more detailed description drop a note.

---

<div class="post-metadata">

**Author:** ![cchristo](https://help.nextcloud.com/letter_avatar/cchristo/32/6_22734026db12803ebb3e059622ac3534.png) [@cchristo](https://help.nextcloud.com/u/cchristo)\
**Post date:** [February 11, 2022, 4:15pm UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/6 "2022-02-11T16:15:36Z")

</div>

Hi all

On android:  
Use DAVx to sync Contacts & Calendars with your android calendar (like google calendar)

---

<div class="post-metadata">

**Author:** ![rozlav](https://help.nextcloud.com/letter_avatar/rozlav/32/6_22734026db12803ebb3e059622ac3534.png) [@rozlav](https://help.nextcloud.com/u/rozlav)\
**Post date:** [April 15, 2022, 10:25am UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/7 "2022-04-15T10:25:04Z")

</div>

Ohaï !

Thank you so much @nicooo !

For your \*\*sharing a google calendar in nextcloud \*\* method, do you have any way or idea to make this work with private calendar that needs credentials ?

I tried to find documentation on how I could add them credentials in the url (which I guess is a very bad security habit even if https), or if there was any pop-up/window prompt functionnality to ask for credentials within Nextcloud but meeh

╮(─▽─)╭

If anyone have an idea that would save me, thanks again !

---

<div class="post-metadata">

**Author:** ![rodinux](https://help.nextcloud.com/user_avatar/help.nextcloud.com/rodinux/32/44316_2.png) [@rodinux](https://help.nextcloud.com/u/rodinux)\
**Post date:** [June 30, 2022, 2:35pm UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/8 "2022-06-30T14:35:04Z")

</div>

Hi, you can suscribe to a private google calendar without credentials with ical the private link…

---

<div class="post-metadata">

**Author:** ![rodinux](https://help.nextcloud.com/user_avatar/help.nextcloud.com/rodinux/32/44316_2.png) [@rodinux](https://help.nextcloud.com/u/rodinux)\
**Post date:** [June 30, 2022, 2:57pm UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/9 "2022-06-30T14:57:53Z")

</div>

I just add this hack to do if you sync a google calendar on your Nextcloud Calendar.

The refresh rate of a calendar subscription in Nextcloud is once every week by default.

[https://docs.nextcloud.com/server/19/user\_manual/pim/calendar.html](https://docs.nextcloud.com/server/19/user_manual/pim/calendar.html)

> Subscriptions are refreshed every week by default. Your admin may have changed this setting.

Change the refresh rate:

- Connect with a terminal in ‘root’ to the Nextcloud instance.
- Position yourself at the root of the Nextcloud site.  
`cd /var/www/nextcloud.example.com/www/ # For example`
- Get the owner of the ‘config.php’ file.

```auto
ls -l config/config.php
.rw-r----- nextcloud nextcloud 1.5 KB Wed May 25 10:17:35 2022 config/config.php

```

- Change the value of the ‘calendarSubscriptionRefreshRate’ option of the Nextcloud calendar app to 5 minutes.

```auto
sudo -u nextcloud php8.0 occ config:app:set dav calendarSubscriptionRefreshRate --value "PT5M"
# Résultat :
# Config value calendarSubscriptionRefreshRate for app dav set to PT5M

```

- Use the user who owns the config file.php with the sudo command. Use the php binary corresponding to the Nextcloud version.
- Check the consideration.

```auto
sudo -u nextcloud php8.0 occ config:list | grep -i calendar
# Résultat :
# "calendar": {
# "calendarSubscriptionRefreshRate": "PT5M",

```

## Crontab

- Edit the crontab of the user who owns the config file.php seen above.

```auto
sudo -u nextcloud crontab -e

```

- Add a task every 5 minutes running the php script located at the root of the Nextcloud site.

```auto
*/5 * * * * php8.0 -f /var/www/nextcloud.example.com/www/cron.php

```

- Use the php binary corresponding to the Nextcloud version.
- Log in as ‘admin’ on the Nextcloud web interface. Then go to **Settings**.
- In the **Administration** section at the bottom left, go to **Basic Settings**.
- Ensure that **Background Tasks** are configured with ‘Cron’.  
 ![469843cdec6eff1063dff5d85c2f4f1be470e429_2_690x173](https://help.nextcloud.com/uploads/default/original/3X/6/2/628ac7608378cc5963ed27144629b710817e4808.png)

## Sources

[https://www.aukfood.fr/nextcloud-ajouter-un-calendrier-google-prive-sans-credentials/](https://www.aukfood.fr/nextcloud-ajouter-un-calendrier-google-prive-sans-credentials/)  
[Using the Calendar app — Nextcloud latest User Manual latest documentation](https://docs.nextcloud.com/server/19/user_manual/pim/calendar.html)  
[Calendar / CalDAV — Nextcloud latest Administration Manual latest documentation](https://docs.nextcloud.com/server/latest/admin_manual/groupware/calendar.html#refresh-rate)  
[PHP: DateInterval::\_\_construct - Manual](https://www.php.net/manual/fr/dateinterval.construct.php)

---

<div class="post-metadata">

**Author:** ![florom](https://help.nextcloud.com/letter_avatar/florom/32/6_22734026db12803ebb3e059622ac3534.png) [@florom](https://help.nextcloud.com/u/florom)\
**Post date:** [July 1, 2022, 6:12am UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/10 "2022-07-01T06:12:25Z")

</div>

Hi @rodinux ,

Can you eleborate what makes a private ical link different from an ical link?

I am unsure what the hack is. You change the refresh interval as described in the Admin documentation too.

---

<div class="post-metadata">

**Author:** ![B\_E](https://help.nextcloud.com/user_avatar/help.nextcloud.com/b_e/32/53537_2.png) [@B\_E](https://help.nextcloud.com/u/B_E)\
**Post date:** [August 5, 2023, 6:59am UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/11 "2023-08-05T06:59:56Z")

</div>

Thanks works very well

---

<div class="post-metadata">

**Author:** ![jernextome](https://help.nextcloud.com/letter_avatar/jernextome/32/6_22734026db12803ebb3e059622ac3534.png) [@jernextome](https://help.nextcloud.com/u/jernextome)\
**Post date:** [February 2, 2024, 4:20pm UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/12 "2024-02-02T16:20:42Z")

</div>

I’m trying to add a friend’s Google Calendar to my Nextcloud (28.0.1), using the “new subscription from link” feature.

We got the link in my friend’s Google Calendar admin interface, where it reads something like private read-only iCal link. Except the link points to an .ics file. In fact, the URL itself ends with .ics. We didn’t find anything closer to “secret address in ical format”.

Nothing happens, even a week later.

I can download the .ics and import it successfully in the Agenda settings. But obviously, this is not what I’m after.

Are we using the wrong link? Did Google change anything?

Is it the correct link and somehow Nextcloud fails at subscribing/refreshing? (This is the new installation and I never subscribed to any other calendar.)

* * *

Subsidiary question about refresh rate. The docs read

> Calendar subscriptions are cached on server and refreshed periodically. The default refresh rate is one week, unless the subscription itself tells otherwise.

but I don’t see how to change the refresh rate for a given subscription.

The docs and the post above only teach how to change the default as admin.

---

<div class="post-metadata">

**Author:** ![rodinux](https://help.nextcloud.com/user_avatar/help.nextcloud.com/rodinux/32/44316_2.png) [@rodinux](https://help.nextcloud.com/u/rodinux)\
**Post date:** [February 23, 2024, 12:46am UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/13 "2024-02-23T00:46:26Z")

</div>

If you have access to your server by ssh, go to the root folder where nextcloud is installed.  
Here the user is `nextcloud`, look first who is the user, it can be `www-data` for example, depends of how it have been installed

```auto
cd /var/www/netcloud 
sudo -u nextcloud php occ config:app:set dav calendarSubscriptionRefreshRate --value "PT15M"

```

For my case, with another php version and with `apc.enable_cli=1` in the conf I have to do this

```auto
cd /var/www/netcloud ;\
sudo -u nextcloud php8.2 --define apc.enable_cli=1 occ config:app:set dav calendarSubscriptionRefreshRate --value "PT15M"

```

But since version 28 (or before ?) it did not works anymore with the private link…  
I have an error like this in the logs

```auto
"line":1199,"function":"createExtendedCollection","class":"OCA\\DAV\\CalDAV\\CalendarHome","type":"->","args":[" ***sensitive parameters replaced***"]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":560,"function":"createCollection","class":"Sabre\\DAV\\Server","type":"->","args":[" ***sensitive parameters replaced***"]},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpMkcol","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":370,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":172,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","Line":130}}},"message":"An exception occurred while executing a query: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction","exception":{},"CustomMessage":"An exception occurred while executing a query: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction"}}

```

---

<div class="post-metadata">

**Author:** ![masterwishx](https://help.nextcloud.com/letter_avatar/masterwishx/32/6_22734026db12803ebb3e059622ac3534.png) [@masterwishx](https://help.nextcloud.com/u/masterwishx)\
**Post date:** [March 4, 2024, 2:30pm UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/14 "2024-03-04T14:30:38Z")

</div>

Thanks a lot for your hint , do you think 5min or 15min is better to setup ?

---

<div class="post-metadata">

**Author:** ![masterwishx](https://help.nextcloud.com/letter_avatar/masterwishx/32/6_22734026db12803ebb3e059622ac3534.png) [@masterwishx](https://help.nextcloud.com/u/masterwishx)\
**Post date:** [March 4, 2024, 2:40pm UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/15 "2024-03-04T14:40:27Z")

</div>

> [@rodinux](#):
>
> But since version 28 (or before ?) it did not works anymore with the private link…  
> I have an error like this in the logs

For me still working fine, using [linuxserver.io](http://linuxserver.io) container …

---

<div class="post-metadata">

**Author:** ![neofax](https://help.nextcloud.com/user_avatar/help.nextcloud.com/neofax/32/64428_2.png) [@neofax](https://help.nextcloud.com/u/neofax)\
**Post date:** [August 30, 2024, 2:10pm UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/16 "2024-08-30T14:10:34Z")

</div>

When I try to add my calendar to NextCloud, I get the following error:

```auto
An exception occurred while executing a query: SQLSTATE[HY000]: General error: 5 database is locked

```

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [January 16, 2025, 9:17am UTC](https://help.nextcloud.com/t/sync-share-google-calendar-nextcloud-calendar/114131/17 "2025-01-16T09:17:53Z")

</div>


