Skip to content

Tutorials

87 Topics 628 Posts

NodeBB guides, how-to's and general tips and tricks

  • [FAQ] Websockets not working due to misconfigured origins

    Pinned faq
    1
    8 Votes
    1 Posts
    16k Views
    PitaJP
    This FAQ is applicable for the following situations: You're receiving the following error in the Javascript console: WebSocket connection to 'wss://<site>/socket.io/?EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 400 The "Looks like your connection to NodeBB was lost, please wait while we try to reconnect." alert box and the spinner in the navbar consistently appear You want your users to be able to access NodeBB from multiple subdomains on your site Background By default, NodeBB only allows websocket connections from the "url" value in config.json. This is because of what is called Cross-Site Websocket Hijacking. By restricting the origin at which sockets can connect, we prevent this attack from taking place. Diagnosis To make sure that your issue is in fact caused by an origin mismatch, try this: Stop the NodeBB server: ./nodebb stop Start NodeBB in dev mode: ./nodebb dev Visit your site, and see if the issue is resolved. Ctrl+C to exit dev mode If the issue disappeared when visiting your site running in dev mode, then your problem is in fact an origin mismatch. If not, it is likely something else, so look around or ask a question here on the forum. Solutions The easiest solution is to set the "url" value in config.json to exactly the URL at which you access your NodeBB forum. For instance, the configuration for this site is { "url": "https://community.nodebb.org", ... } If you want your forum to work from multiple origins (like www.yoursite.com and yoursite.com) the preferred option is to just redirect one to the other. For instance, redirect www.yoursite.com to yoursite.com within your reverse proxy. If you absolutely must have full access from multiple origins, you can configure the accepted origins directly. As documented here, you can add a socket.io:origins property to config.json. For example, to allow accessing the forum sockets from the main NodeBB site, nodebb.org, the following would be added to our config: { ... "socket.io": { "origins": "https://community.nodebb.org:* https://nodebb.org:*" } } Make sure your original site is included in the new origins property, and that you add :*, otherwise it's invalid. Still having issues? It's likely a reverse proxy configuration issue. Take a look at the proxy documentation for examples. If you still have issues, ask a question here on the forum.
  • How to remove google fonts from skins

    2
    3 Votes
    2 Posts
    561 Views
    julianJ
    Thanks for sharing! The font integration is definitely tricky to get right! Glad you were able to make it work.
  • Custom javascript to display html on /compose route

    composer
    10
    1
    5 Votes
    10 Posts
    5k Views
    <baris>B
    Topic templates will be part of core next patch release. https://github.com/NodeBB/NodeBB/issues/13649 [image: 1757512218514-104729a7-eb1f-4dc7-9ddd-6331a5d92e26-image.png]
  • NodeBB Container Fails to Start – Redis Connection Error

    1
    0 Votes
    1 Posts
    729 Views
    zy zhangZ
    Hi everyone, My NodeBB instance suddenly shut down today, and I haven’t been able to get it running again. I’d appreciate any help! I’ve tried restarting it with: docker compose down docker compose up But NodeBB still fails to start. For privacy, I’ve masked the NodeBB URL as xxxxxx(nodebb link) and the IP as nodebb_ip in the logs below. Thanks for understanding. Here's the output log of docker compose up: >docker compose up [+] Running 3/0 ✔ Network bbs_default Created 0.0s ✔ Container redis Created 0.0s ✔ Container nodebb Created 0.0s Attaching to nodebb, redis redis | 1:C 01 Aug 2025 04:31:03.343 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. redis | 1:C 01 Aug 2025 04:31:03.343 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo redis | 1:C 01 Aug 2025 04:31:03.343 * Redis version=7.4.2, bits=64, commit=00000000, modified=0, pid=1, just started redis | 1:C 01 Aug 2025 04:31:03.343 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf redis | 1:M 01 Aug 2025 04:31:03.344 * Increased maximum number of open files to 10032 (it was originally set to 1024). redis | 1:M 01 Aug 2025 04:31:03.344 * monotonic clock: POSIX clock_gettime redis | 1:M 01 Aug 2025 04:31:03.345 * Running mode=standalone, port=6379. redis | 1:M 01 Aug 2025 04:31:03.345 * Server initialized redis | 1:M 01 Aug 2025 04:31:03.345 * Loading RDB produced by version 7.4.2 redis | 1:M 01 Aug 2025 04:31:03.345 * RDB age 46 seconds redis | 1:M 01 Aug 2025 04:31:03.345 * RDB memory usage when created 2.67 Mb redis | 1:M 01 Aug 2025 04:31:03.357 * Done loading RDB, keys loaded: 4094, keys expired: 0. redis | 1:M 01 Aug 2025 04:31:03.357 * DB loaded from disk: 0.012 seconds redis | 1:M 01 Aug 2025 04:31:03.357 * Ready to accept connections tcp nodebb | /bin/sh: 1: ./entrypoint.sh: not found nodebb | nodebb | Starting NodeBB nodebb | "./nodebb stop" to stop the NodeBB server nodebb | "./nodebb log" to view server output nodebb | "./nodebb help" for more commands nodebb | nodebb | nodebb | NodeBB v4.4.4 Copyright (C) 2013-2025 NodeBB Inc. nodebb | This program comes with ABSOLUTELY NO WARRANTY. nodebb | This is free software, and you are welcome to redistribute it under certain conditions. nodebb | For the full license, please visit: http://www.gnu.org/copyleft/gpl.html nodebb | nodebb | Clustering enabled: Spinning up 1 process(es). nodebb | nodebb | 2025-08-01T04:31:04.152Z [4567/27] - info: Initializing NodeBB v4.4.4 xxxxxx(nodebb link) nodebb | 2025-08-01T04:31:04.208Z [4567/27] - error: Error: connect EHOSTUNREACH nodebb_ip:6379 nodebb | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1636:16) nodebb | 2025-08-01T04:31:04.209Z [4567/27] - error: Error: connect EHOSTUNREACH nodebb_ip:6379 nodebb | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1636:16) nodebb | [cluster] Child Process (27) has exited (code: 0, signal: null) nodebb exited with code 0 ^CGracefully stopping... (press Ctrl+C again to force) [+] Stopping 2/2 ✔ Container nodebb Stopped 0.0s ✔ Container redis Stopped 0.1s canceled Below are the contents of my docker-compose.yml and config.json: docker-compose.yml services: nodebb: image: elestio/nodebb user: root container_name: nodebb ports: - 4567:4567 volumes: - ./config.json:/usr/src/app/config.json - ./data/public/uploads:/usr/src/app/public/uploads depends_on: - redis redis: image: redis:alpine container_name: redis volumes: - ./redis-data:/data config.json { "url": "xxxxxx(nodebb link)", "secret": "cef0a69d-45ad-40b0-bcef-2adf393ef9ea", "database": "redis", "port": "4567", "redis": { "host": "redis", "port": "6379", "password": "", "database": "0" } } Any suggestions would be greatly appreciated! Thanks in advance, Zhanye
  • Long running drafts and scheduled topics

    drafts scheduled topics harmony 3.x
    6
    2
    0 Votes
    6 Posts
    2k Views
    K
    Oh, this is actually pretty great. I didn't notice the scheduled post feature before. I've just been saving drafts to a category that only I have access to. Is there a way to filter for, or filter out, scheduled posts?
  • How can I move Bookmark in Topic's tool?

    5
    1
    0 Votes
    5 Posts
    1k Views
    <baris>B
    Did you give it the same component attribute as the one in the dropdown? https://github.com/NodeBB/NodeBB/blob/master/public/src/client/topic/postTools.js#L128-L130 This is the click handler. You also need data-bookmarked on the button, each post object has a bookmarked and bookmarks property.
  • [manual] Build a Night Mode for Harmony

    harmony widget nightmode
    7
    2
    11 Votes
    7 Posts
    4k Views
    Kadir Ay 0K
    @baris Yes we haven't published yet but its public , we are fixing bugs , developing and arranging for our university . We would be pleased if you take a look . - forum.ieu.app -
  • how do you use sort-by-title

    2
    0 Votes
    2 Posts
    828 Views
    Z
    not sure the plugin worked for firefox. saw a-z in the sort icon. when i used it, i expected the topics in the category would be sorted a-z. they werent
  • How to write hooks

    plugin development hooks 1.17.0
    5
    6 Votes
    5 Posts
    3k Views
    <baris>B
    Quick start plugin has an example on how to add a new api route https://github.com/NodeBB/nodebb-plugin-quickstart/blob/master/library.js#L40-L76. The hooks that are fired client side are for client side code in plugins. If you want to pass data from the client to the server you have two options. Create an api route like in quick start plugin Create a new socket event listener on the server side and use socket.emit() client side. Example here
  • How do I create footer for more information, text and links

    Moved Solved
    8
    1 Votes
    8 Posts
    3k Views
    phenomlabP
    @frontendjulien Always happy to help.
  • Card view with CSS and some custom JS

    cards functions
    25
    1
    6 Votes
    25 Posts
    10k Views
    phenomlabP
    For anyone following this thread, new stable release is here. If you use Cloudflare, please also see notes around that https://sudonix.org/post/8433
  • Running NodeBB using Rootless Podman and Nobbic

    podman containers vps docker installer
    2
    1 Votes
    2 Posts
    1k Views
    ernstkiE
    @nhl-pl Good resource, thanks for sharing!
  • How to create a "New Topic" button in header

    24
    1
    12 Votes
    24 Posts
    13k Views
    <baris>B
    @saikarthikp9 https://www.screentogif.com/
  • Create a public chat room dropdown in navigation

    chats
    5
    2
    6 Votes
    5 Posts
    2k Views
    DownPWD
    Thanks dude @baris Works great know on Smartphone an Desktop Love it !
  • Stats of categories as a progress bars on GitHub

    harmony stats
    6
    1
    6 Votes
    6 Posts
    2k Views
    crazycellsC
    @baris I think even for tags, this "distribution bar" above makes more sense than the "progress bar" since tags are not competing with each other to reach #264... so, their "progress" is not that important... [image: 1691713412155-screen-shot-2023-08-10-at-20.18.17.png]
  • [manual] Build a custom header in Harmony

    Moved 3.0.0 modification harmony
    25
    3 Votes
    25 Posts
    9k Views
    E
    @baris Awesome, thank you!
  • Using Gmail as your mailer for NodeBB

    9
    2 Votes
    9 Posts
    5k Views
    PitaJP
    @S-Yang indeed, mailer putting take precedence over the built-in SMTP mailer.
  • Using CloudFlare with NodeBB

    nodebb websocket websockets cloudflare proxy
    106
    15 Votes
    106 Posts
    111k Views
    phenomlabP
    @DownPW I'm not sure it's solely traffic that causes this. I took saw this frequently when I used Cloudflare and it became so bad that I decided to stop using the service altogether. No issues since.
  • Run NodeBB in the Docker or Kubernetes

    11
    6 Votes
    11 Posts
    6k Views
    J
    @Sebastix to reset admin password run: . /nodebb user reset 1 --pssword
  • Setup OGProxy for use in NodeBB

    6
    1 Votes
    6 Posts
    2k Views
    phenomlabP
    @brazzerstop yep. Already discussed with Julian. Hotlink protect is enabled on my domain. I've seen numerous cases whilst writing the server sudonix uses, and so I fill the gap with a pretty 404 image.

Looks like your connection to NodeBB Community was lost, please wait while we try to reconnect.