Nostr is a new decentralized social network protocol. This guide is the easiest way to get started running your own Nostr Relay and participating in the network. From 0 to 100 in under 5 minutes.
Currently it's sub 1GB in data storage. I'd say anything in the 50GB will allow your relay to grow quite a bit before you need to worry? Not sure. New territory to be honest.
Could you elaborate a bit on *why* one might want to run their own relay? Does it offer certain advantages (e.g. security,…)? Or does it simply help the network scale?
When I upload a file (jpeg/mp4) to my nostream relay, the file itself gets uploaded to a linode server somewhere. How do I have my file uploaded to my machine instead?
When I start the relay with "npm run docker:compose:start" I got following error message:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/testuser/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/testuser/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
Just wondering why the error points to the package file in user home folder and not to the nostream folder.
############################################
When I start the relay in folder nostream I got following error message:
> nostream@1.19.0 docker:compose:start
> ./scripts/start
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.project%3Dnostream%22%3Atrue%7D%7D": dial unix /var/run/docker.sock: connect: permission denied
FATAL: could not map anonymous shared memory: Cannot allocate memory
nostream-db | 2023-02-03 00:04:10.019 UTC [1] HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 4438917120 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections
Looks like my VM doesn´t meet the required system requirements. But I can´t find any minimum requirements for a nostr relay.
Not sure where to look for a more comprehensive log (the fragment below is copied from the screen ) for container db nor how to address the issue.
```
db | 2023-01-14 07:58:01.548 UTC [1] FATAL: could not map anonymous shared memory: Cannot allocate memory
db | 2023-01-14 07:58:01.548 UTC [1] HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 4438917120 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
db | 2023-01-14 07:58:01.549 UTC [1] LOG: database system is shut down
db exited with code 1
container for service "db" is unhealthy
```
ChatGPT has made some sensible suggestions but being a naïf at Docker, I don't think I'll take the risk without guidance, any gratefully received. Oh, except, get a bigger boat.
PS. ChatGPT was wrong about the triple back tick giving monospace format, but I left the intention in place.
Also, everything seems to be working with my relay when I use only it with a client like https://astral.ninja but none of my posts seem to be seen by other clients - it's like it's not getting relayed somehow - any thoughts on how to debug that? I don't seen any obv error/warning messages from the docker logs on my relay.
minor typo:
sudo certbot —nginx -d subdomain.mydomain.com
should be:
sudo certbot --nginx subdomain.mydomain.com
Neither of these worked for me, I get "unrecognised arguments: subdomain.domain.com"
You need to pass the `-d` for `domain`. The issue was on copy-pasting from my CLI it combined two dashes into a single longer dash.
sudo certbot --nginx -d subdomain.mydomain.com
That's the correct one. It's been fixed in the post as well.
what would you say is the safe amount to dedicate for storage?
Currently it's sub 1GB in data storage. I'd say anything in the 50GB will allow your relay to grow quite a bit before you need to worry? Not sure. New territory to be honest.
what do you differently on the zbd relay that seems to be faring well with the spikes in volume?
Likely just bigger specs? Not sure
Great guide, thank you very much! I made it to the last step, but keep getting this error when I run npm run docker:compose:start
failed to solve: executor failed running [/bin/sh -c npm run build]: exit code: 2
Anyone else run into that issue?
Could you elaborate a bit on *why* one might want to run their own relay? Does it offer certain advantages (e.g. security,…)? Or does it simply help the network scale?
Why didn't you mention an AAA record? Is IPv6 not supported?
Hi, its necessary a fix IP to run the node?
i am trying from my localhost server, with a dinamic IP.
When I upload a file (jpeg/mp4) to my nostream relay, the file itself gets uploaded to a linode server somewhere. How do I have my file uploaded to my machine instead?
```
$ npm run docker:compose:start
> nostream@1.25.2 docker:compose:start
> ./scripts/start
Creating folder /home/ubuntu/www/break-19.com/relay.break-19.com/scripts/../.nostr
Copying /home/ubuntu/www/break-19.com/relay.break-19.com/scripts/../resources/default-settings.yaml to /home/ubuntu/www/break-19.com/relay.break-19.com/scripts/../.
nostr/settings.yaml
unknown shorthand flag: 'f' in -f
See 'docker --help'.
Usage: docker [OPTIONS] COMMAND
```
your instructions is broked.
Is the graphic at the top of the article a network diagram of all the current relays? Thanks
would this work on a mac? not with the same cli commands ofcourse
So if I copy pasta that code you posted into a container on my VM it would work? Sorry if its a dumb question No code dude here trying to learn!
When I start the relay with "npm run docker:compose:start" I got following error message:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/testuser/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/testuser/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
Just wondering why the error points to the package file in user home folder and not to the nostream folder.
############################################
When I start the relay in folder nostream I got following error message:
> nostream@1.19.0 docker:compose:start
> ./scripts/start
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.project%3Dnostream%22%3Atrue%7D%7D": dial unix /var/run/docker.sock: connect: permission denied
##################################################
..and with sudo "npm...:
> nostream@1.19.0 docker:compose:start
> ./scripts/start
WARNING: Error loading config file: /root/.docker/config.json: open /root/.docker/config.json: permission denied
unknown shorthand flag: 'f' in -f
Any idea? Thx.
getting the exact same error.
figured it out, just needed to add user to docker group
`sudo usermod -aG docker ${USER}`
This worked for me.. THANK YOU.
This newer version of the guide fixed it for me: https://andreneves.xyz/p/how-to-setup-a-paid-nostr-relay?utm_source=substack&utm_campaign=post_embed&utm_medium=web
Just ran it minus the payments stuff.
That didn't seem to work in my case. Even when I switch users away from root with 'su', after I run docker-compose:start I get:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /root/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/root/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-02-22T23_24_17_093Z-debug-0.log
dito, but now I get a PostgreSQL error:
FATAL: could not map anonymous shared memory: Cannot allocate memory
nostream-db | 2023-02-03 00:04:10.019 UTC [1] HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 4438917120 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections
Looks like my VM doesn´t meet the required system requirements. But I can´t find any minimum requirements for a nostr relay.
Not sure where to look for a more comprehensive log (the fragment below is copied from the screen ) for container db nor how to address the issue.
```
db | 2023-01-14 07:58:01.548 UTC [1] FATAL: could not map anonymous shared memory: Cannot allocate memory
db | 2023-01-14 07:58:01.548 UTC [1] HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 4438917120 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
db | 2023-01-14 07:58:01.549 UTC [1] LOG: database system is shut down
db exited with code 1
container for service "db" is unhealthy
```
ChatGPT has made some sensible suggestions but being a naïf at Docker, I don't think I'll take the risk without guidance, any gratefully received. Oh, except, get a bigger boat.
PS. ChatGPT was wrong about the triple back tick giving monospace format, but I left the intention in place.
Do you know alternative without available static IP address? Something like no-ip.org that works for nostr...
This is cool - thanks, minor suggestions:
1) Need "sudo apt update" after doing "# Setup `apt` Docker repository"
2) Need to cp not mv here: "mv settings.sample.json ~/.nostr/settings.json" because on startup it will error if $PWD/settings.sample.json doesn't exist since it uses it for [defaults](https://github.com/Cameri/nostream/blob/c150cb2be5a03043d079e4eb31b6393f7971954f/src/utils/settings.ts#L43)
Also, everything seems to be working with my relay when I use only it with a client like https://astral.ninja but none of my posts seem to be seen by other clients - it's like it's not getting relayed somehow - any thoughts on how to debug that? I don't seen any obv error/warning messages from the docker logs on my relay.