# Question: HOW TO - NTFY service

**URL:** https://forum.yunohost.org/t/question-how-to-ntfy-service/25990
**Category:** Support apps
**Tags:** ntfy, english
**Created:** [August 15, 2023, 6:57am UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990 "2023-08-15T06:57:16Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![ghose](https://forum.yunohost.org/user_avatar/forum.yunohost.org/ghose/32/10939_2.png) [@ghose](https://forum.yunohost.org/u/ghose)
#### Post date: [August 15, 2023, 6:57am UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990/1 "2023-08-15T06:57:16Z")

</div>

## My YunoHost server

**Hardware:** VPS bought online  
**YunoHost version:** 11.2.3 (stable)  
**I have access to my server :** Through SSH | through the webadmin  
**Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?** : no  
**If yes, please explain:**  
**If your request is related to an app, specify its name and version:** 2.6.2~ynh1

### Description of my issue

**TL;DR:** I don’t get notifications in my android device and _cli_ test does not work either. Please, have anyone step by step set up instructions? thank you.

### What have I done?

- installed **ynh-ntfy** app in my server, without issues (apparently)

- added this app to “individual user permission” (my user, ntfy); also to Admins group as read here [Ntfy just not working after install - #8 by tituspijean](https://forum.yunohost.org/t/ntfy-just-not-working-after-install/24384/8) (not clear what/how has to be added)

- installed nfty **ANDROID** app, added my server url, installed Unifiedpush Example app for testing purposes. It helped me in another device (using nextpush service) to test connection.

- this Example App registers in nfty-android app (as FluffyChat does) but in the app ntfy-android, for **all** topics says `reconnecting...`

I’ve tried both websockets (with warning about possible ngix further configuration) and json method without success.

- I’ve selected “using Websockets” as connection method for the android app as sugested (json method does not work either)

I’m subscribed to “test” topic in android-ntfy, but when send this to topic:

```auto
curl -d "testing ntfy" ntfy.domain.noho.st/test
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

```

I can access _ntfy-ynh_ webinterface from user portal (admin user), and tried to publish to `test` there, but I get `Error 40101: unauthorized`

I also created a dummy test user in that web interface.

About users: [NTFY - création de compte utilisateur - #2 by tituspijean](https://forum.yunohost.org/t/ntfy-creation-de-compte-utilisateur/22560/2) and [[RÉSOLU] Gestion des utilisateurs ntfy en cli : message d'erreur](https://forum.yunohost.org/t/resolu-gestion-des-utilisateurs-ntfy-en-cli-message-derreur/23556), but I don’t think it’s a “users” problem as I don’t restrict access to this server (yet)

Please, **what am I missing?** thank you

This is `journalctl` log from last service restart (copied from ynh admin web interface)

```auto
Aug 15 06:45:11 systemd[1]: Stopping ntfy server...
Aug 15 06:45:11 systemd[1]: ntfy.service: Succeeded.
Aug 15 06:45:11 systemd[1]: Stopped ntfy server.
Aug 15 06:45:11 systemd[1]: ntfy.service: Consumed 1.368s CPU time.
Aug 15 06:45:11 systemd[1]: Started ntfy server.
Aug 15 06:45:11 ntfy[3826]: 2023/08/15 06:45:11 INFO Listening on localhost:8080[http], ntfy 2.6.2, log level is INFO (tag=startup)
Aug 15 06:46:11 ntfy[3826]: 2023/08/15 06:46:11 INFO Server stats (emails_received=0, emails_received_failure=0, emails_received_success=0, emails_sent=0, emails_sent_failure=0, emails_sent_success=0, messages_cached=0, messages_published=0, subscribers=0, tag=manager, topics_active=0, users=2, visitors=0)
Aug 15 06:47:11 ntfy[3826]: 2023/08/15 06:47:11 INFO Server stats (emails_received=0, emails_received_failure=0, emails_received_success=0, emails_sent=0, emails_sent_failure=0, emails_sent_success=0, messages_cached=0, messages_published=0, subscribers=0, tag=manager, topics_active=0, users=2, visitors=0)
Aug 15 06:48:11 ntfy[3826]: 2023/08/15 06:48:11 INFO Server stats (emails_received=0, emails_received_failure=0, emails_received_success=0, emails_sent=0, emails_sent_failure=0, emails_sent_success=0, messages_cached=0, messages_published=0, subscribers=0, tag=manager, topics_active=0, users=2, visitors=0)
Aug 15 06:49:11 ntfy[3826]: 2023/08/15 06:49:11 INFO Server stats (emails_received=0, emails_received_failure=0, emails_received_success=0, emails_sent=0, emails_sent_failure=0, emails_sent_success=0, messages_cached=0, messages_published=0, subscribers=0, tag=manager, topics_active=0, users=2, visitors=0)
Aug 15 06:50:11 ntfy[3826]: 2023/08/15 06:50:11 INFO Server stats (emails_received=0, emails_received_failure=0, emails_received_success=0, emails_sent=0, emails_sent_failure=0, emails_sent_success=0, messages_cached=0, messages_published=0, subscribers=0, tag=manager, topics_active=0, users=2, visitors=0)
Aug 15 06:51:11 ntfy[3826]: 2023/08/15 06:51:11 INFO Server stats (emails_received=0, emails_received_failure=0, emails_received_success=0, emails_sent=0, emails_sent_failure=0, emails_sent_success=0, messages_cached=0, messages_published=0, subscribers=0, tag=manager, topics_active=0, users=2, visitors=0)
Aug 15 06:52:11 ntfy[3826]: 2023/08/15 06:52:11 INFO Server stats (emails_received=0, emails_received_failure=0, emails_received_success=0, emails_sent=0, emails_sent_failure=0, emails_sent_success=0, messages_cached=0, messages_published=0, subscribers=0, tag=manager, topics_active=0, users=2, visitors=0)
Aug 15 06:53:11 ntfy[3826]: 2023/08/15 06:53:11 INFO Server stats (emails_received=0, emails_received_failure=0, emails_received_success=0, emails_sent=0, emails_sent_failure=0, emails_sent_success=0, messages_cached=0, messages_published=0, subscribers=0, tag=manager, topics_active=0, users=2, visitors=1)
Aug 15 06:54:11 ntfy[3826]: 2023/08/15 06:54:11 INFO Server stats (emails_received=0, emails_received_failure=0, emails_received_success=0, emails_sent=0, emails_sent_failure=0, emails_sent_success=0, messages_cached=0, messages_published=0, subscribers=0, tag=manager, topics_active=0, users=2, visitors=1)

```

thank you

---

<div class="post-metadata">

### Author: ![rvailleux](https://forum.yunohost.org/user_avatar/forum.yunohost.org/rvailleux/32/8414_2.png) [@rvailleux](https://forum.yunohost.org/u/rvailleux)
#### Post date: [August 17, 2023, 7:14pm UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990/2 "2023-08-17T19:14:51Z")

</div>

Hi @ghose,  
Same here! 👋 Keep you posted if I find a solution.

---

<div class="post-metadata">

### Author: ![rvailleux](https://forum.yunohost.org/user_avatar/forum.yunohost.org/rvailleux/32/8414_2.png) [@rvailleux](https://forum.yunohost.org/u/rvailleux)
#### Post date: [August 17, 2023, 8:11pm UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990/4 "2023-08-17T20:11:27Z")

</div>

As far as I understand:  
You need to be authenticated to read and post on topics.

Here is the doc on how to use Bearer tokens in your curl command: [Sending messages - ntfy](https://ntfy.sh/docs/publish/?h=authen#access-tokens)

cheers

---

<div class="post-metadata">

### Author: ![ghose](https://forum.yunohost.org/user_avatar/forum.yunohost.org/ghose/32/10939_2.png) [@ghose](https://forum.yunohost.org/u/ghose)
#### Post date: [August 18, 2023, 3:45am UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990/5 "2023-08-18T03:45:38Z")

</div>

thank you.

we all would thank some guidance

log (from mobile device)

```auto
1692330018562 2023-08-18 05:40:18.562 D NtfyWsConnection ntfy.domain.host/tests,5ZVXPOAVHpdTaxn6 (gid=3): Opening https://ntfy.domain.host/tests,5ZVXPOAVHpdTaxn6/ws?since=none with listener ID 7 ...
1692330018652 2023-08-18 05:40:18.652 E NtfyWsConnection ntfy.domain.host/tests,5ZVXPOAVHpdTaxn6 (gid=3, lid=7): Connection failed (response code 200, message: OK): Expected HTTP 101 response but was '200 OK'
Exception:
java.net.ProtocolException: Expected HTTP 101 response but was '200 OK'
	at okhttp3.internal.ws.RealWebSocket.checkUpgradeSuccess$okhttp(RealWebSocket.kt:224)
	at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:170)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:923)

```

---

<div class="post-metadata">

### Author: ![serversonic](https://forum.yunohost.org/user_avatar/forum.yunohost.org/serversonic/32/8447_2.png) [@serversonic](https://forum.yunohost.org/u/serversonic)
#### Post date: [August 24, 2023, 11:06am UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990/6 "2023-08-24T11:06:14Z")

</div>

I’ve worked this out today:

The application is created with an admin user which you set the password for. However it’s created with no specific permissions on the Yunohost portal - you can see it’s set to nobody.  
I’ve changed that to Visitors and the admin user can now publish and subscribe with username and password, and a token if you create one. You can also log into the web app, which isn’t available if you don’t enable Visitors.  
I’ve also created a non-admin user but that needs a permission defining with `./ntfy.sh access username topicname rw` on the server. Once that’s done, you can also publish and subscribe with that user as well.

---

<div class="post-metadata">

### Author: ![serversonic](https://forum.yunohost.org/user_avatar/forum.yunohost.org/serversonic/32/8447_2.png) [@serversonic](https://forum.yunohost.org/u/serversonic)
#### Post date: [August 24, 2023, 12:04pm UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990/7 "2023-08-24T12:04:55Z")

</div>

I’ve also now set up an app on my phone to use my ntfy instance (Fedilab to be specific, but this should apply to any app that can be configured to use ntfy).

- Configure the ntfy app with your server and credentials (I’ve used user and password, but I should try the token).
- Configure the sending app to use ntfy.
- In ntfy this should create the topics that the app uses, but they will show as reconnecting.
- On the command line grant permission to those topics as above, and the app should connect after a minute or so.

---

<div class="post-metadata">

### Author: ![ghose](https://forum.yunohost.org/user_avatar/forum.yunohost.org/ghose/32/10939_2.png) [@ghose](https://forum.yunohost.org/u/ghose)
#### Post date: [August 25, 2023, 3:35am UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990/8 "2023-08-25T03:35:12Z")

</div>

😃 thank you @serversonic

bookmarked your info and I will try to replicate it in my server.

Thank you so much!

---

<div class="post-metadata">

### Author: ![ghose](https://forum.yunohost.org/user_avatar/forum.yunohost.org/ghose/32/10939_2.png) [@ghose](https://forum.yunohost.org/u/ghose)
#### Post date: [August 26, 2023, 4:18pm UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990/9 "2023-08-26T16:18:42Z")

</div>

> [@serversonic](#):
>
> I’ve changed that to Visitors

wouldn’t it be enough change it to “Users”?

so any YNH logged user could access to ntfy client interface, but not “anonymous” people who eventually know our ntfy server URL. Server is password protected though, but anyway…

I’ve set ntfy as you suggested and at least I could create a “test” topic, send a message from web interface (my server) and being notified in the mobile device after manually subscribe to that topic 😃 It’s a start! Thank you

**edit** : I’m using just the default user/password created on install, not adding a new one (so far)

---

<div class="post-metadata">

### Author: ![serversonic](https://forum.yunohost.org/user_avatar/forum.yunohost.org/serversonic/32/8447_2.png) [@serversonic](https://forum.yunohost.org/u/serversonic)
#### Post date: [August 26, 2023, 5:34pm UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990/10 "2023-08-26T17:34:01Z")

</div>

I tried restricting it to Users and couldn’t get it to work even with the same username and password combination for the Yunohost user and the ntfy user.

In applications the registration process would usually be handled as part of setup - for example an IoT device would contact its registration server and create a token and topic to subscribe to. Or, as has been found far too often, just connect anonymously to an open server. 🫤

---

<div class="post-metadata">

### Author: ![ghose](https://forum.yunohost.org/user_avatar/forum.yunohost.org/ghose/32/10939_2.png) [@ghose](https://forum.yunohost.org/u/ghose)
#### Post date: [August 28, 2023, 9:30am UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990/11 "2023-08-28T09:30:49Z")

</div>

reading documentation about **UnifiedPush** [https://serverntfy/docs/config/#example-unifiedpush](https://serverntfy/docs/config/#example-unifiedpush)

> [UnifiedPush](https://unifiedpush.org) requires that the [application server](https://unifiedpush.org/spec/definitions/#application-server) (e.g. Synapse, Fediverse Server, …) has **anonymous write access** to the [topic](https://unifiedpush.org/spec/definitions/#endpoint) used for push messages. The topic names used by UnifiedPush all start with the `up*` prefix. Please refer to the **[UnifiedPush documentation](https://unifiedpush.org/users/distributors/ntfy/#limit-access-to-some-users)** for more details.

> To enable support for UnifiedPush for private servers (i.e. `auth-default-access: "deny-all"`), you should either allow anonymous write access for the entire prefix or explicitly per topic:

> PrefixExplicitly //// also allows _per topic_ control.

```auto
$ ntfy access '*' 'up*' write-only

```

**Our server.yml** file:

`auth-default-access: "deny-all"`

so when an app as _tusky_ creates a new topic it assumes that it has access, but it has not,

```auto
root@ynh:/var/www/ntfy# ./ntfy access '*' upTOPICcreatedWn write-only
option auth-file not set; auth is unconfigured for this server

```

in server.yml is set

`auth-file: /var/www/ntfy/data/user.db` , this file exist in that location

is it possible to change access to topics from web-UI? I have not seen that option in the topic’s settings

thank you

---

<div class="post-metadata">

### Author: ![system](https://forum.yunohost.org/uploads/default/original/2X/f/f59fe8e3ee6b100b4f574d30d6e30479c68b89f0.png) [@system](https://forum.yunohost.org/u/system)
#### Post date: [September 12, 2023, 9:31am UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990/12 "2023-09-12T09:31:32Z")

</div>

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

---

<div class="post-metadata">

### Author: ![OniriCorpe](https://forum.yunohost.org/user_avatar/forum.yunohost.org/oniricorpe/32/3356_2.png) [@OniriCorpe](https://forum.yunohost.org/u/OniriCorpe)
#### Post date: [January 16, 2024, 6:41pm UTC](https://forum.yunohost.org/t/question-how-to-ntfy-service/25990/13 "2024-01-16T18:41:36Z")

</div>

> [@serversonic](#):
>
> I’ve changed that to Visitors and the admin user can now publish and subscribe with username and password, and a token if you create one. You can also log into the web app, which isn’t available if you don’t enable Visitors.

I made a pull request to fix ntfy by a mandatory exposure of the application to visitors to fix this issue:

> <https://github.com/YunoHost-Apps/ntfy_ynh/pull/34>
>
> \## Problem
> 
> ntfy needs to be exposed to properly work
> see: https://forum.yuno…host.org/t/question-how-to-ntfy-service/25990/6?u=oniricorpe
> see: https://docs.ntfy.sh/subscribe/api/
> 
> \## Solution
> 
> mandatory \`/\` exposure to visitors
> 
> \## PR Status
> 
> \- \[x\] Code finished and ready to be reviewed/tested
> \- \[\] The fix/enhancement were manually tested (if applicable)

edit: the fix will be available soon as v2.8.0~ynh2
