DavidO
(David)
January 7, 2026, 8:10pm
1
I’m trying to rebake 45k posts because I’ve changed the S3 CDN URL and it keeps running out of memory and killing it.
I read this about setting up a swapfile…
For servers with <= 2GB of RAM, running ./discourse-setup will prompt for and automatically create a 2GB swapfile.
Most cloud virtual machine providers do not set up swapfiles as part of their server provisioning.
In particular, upgrading Discourse produces a lot of memory pressure. With a swap file, rather than randomly terminating processes with an out of memory error, things will slow down instead. Having a swap file is a cheap insurance policy that protects you from many other lo…
The first two commands went fine…
Create an empty swapfile
install -o root -g root -m 0600 /dev/null /swapfile
write out a 2GB file named ‘swapfile’
dd if=/dev/zero of=/swapfile bs=1k count=2048k
But then on mkswap /swapfile it gave me an error…
mkswap error swapfile is mounted will not make swapspace
I tried this instead…
What you get from
free
df -h
The install script has detected you have less than 2G of RAM and less than 2G of swap, and is trying to create a swapfile. According to the source , it doesn’t deal with the case where there is an existing swapfile. Probably you should remove the existing swapfile and try again. This might be enough:
swapoff /swapfile && rm /swapfile
free
swapoff /swapfile && rm /swapfile
and got this error…
swapoff: Not superuser
I’m on a Digital Ocean Droplet, so I guess I don’t have the necessary permissions for that?
Hitting those blocks, I tried instead to just rebake uncooked posts running…
rake posts:rebake_uncooked_posts
It will run several hundred, maybe a few thousand if I’m lucky, then kills off again. After babysitting it since yesterday, I’m half baked.
Is there a way to run a rebake command that is throttled? I don’t care if it takes a while, overnight or whatever, I just want it to stop failing.
Any help would be much appreciated.
DavidO
(David)
January 7, 2026, 8:13pm
2
Oddly enough I let the uncooked run again while I was writing all of that up. Left for a long lunch with some friends and came back to it being 100% done. I’m not sure if the swapfile finally started working or if it was just a low use coincidence of timing, but…
done, finally!
Maybe if someone has an answer, it can help someone else or me on the next go round.
DavidO
(David)
January 7, 2026, 8:22pm
4
Thanks. Not sure if I did it right or not.
That doesn’t look right. Which instructions are you following?
And why are you creating swap inside the container? Swap is meant to be created on the host not inside the container.
DavidO
(David)
January 7, 2026, 8:31pm
6
Because I only marginally know what I’m doing.
So that’s at the ubuntu: base level and not the ubuntu:/var/discourse or ubuntu-app:/var/www/discourselevels?
Any ideas on the rebake throttling?
1 Like
I have never seen rebake being throttled, it is asynchronous, it queues the jobs which are processed in the background.
1 Like
DavidO
(David)
January 7, 2026, 8:34pm
8
OK, thank you. Mine finished the rebake for now, so I’ll consider myself lucky and stop messing with it.
Warning : don’t do things blindly on a production site, there is a strong chance of things going wrong without any real way to recover them.
no, it’s not the ubuntu: level.
Did you do a ./launcher enter app before trying to create swap? If yes, that what you shouldn’t have done.
When you first log on to your server is the host, when you enter app, you’re performing actions inside the container.
the swap needs to be created on the host, the application lives inside the container, this is what you will access to run the rebake command.
DavidO
(David)
January 7, 2026, 8:40pm
10
OK, thanks for the guidance.
Our forum is just a group of friends and has good backups, so if I roast it for a week or so, we’ll just have to suffer through GroupMe.
pfaffman
(Jay Pfaffman)
January 7, 2026, 8:47pm
11
This means that you already have a swapfile, it’s called /swapfile, and it’s in use.
If you want to make it bigger, you can stop your container, then unmount it, and then use that dd command to make it bigger, and then the mkswap command.
If someone else reads this, the way that I do it is to grep swap discourse-setup and look at the commands there. It’s a slightly easier version of what to do.
3 Likes
DavidO
(David)
January 7, 2026, 8:49pm
12
I often serve as a cautionary tail.
Thanks for the addition.
1 Like
Canapin
(Coin-coin le Canapin)
January 7, 2026, 11:33pm
13
I don’t know about you, but I was repeatedly going out of memory during a long rebake process. Creating a 2 GB swap improved (more posts got rebaked), but still OOM after a while. Increased swap to 4 GB, and was able to rebake all my posts.
I increased the swap size from 2 to 4 GB, and the rebake worked.
So, I guess it was about memory, though I am a bit surprised by how much it asks (8 GB RAM + 4 GB swap), especially since older rebakes didn’t have any issues with no swap and the same amount of RAM.
What should I do if I want to monitor RAM usage and check for any issues? What metric should matter to estimate the memory requirements? Page views per day (5000-8000 + bot spikes once or twice a month)? Database size (23 GB)? …
I didn’t know anything about swap files besides this guide Create a swapfile for your Linux server , but chatGPT was knowledgeable enough to help me increase my swap without issues.
3 Likes
DavidO
(David)
January 8, 2026, 3:11pm
14
One issue for me is that I don’t have a good grasp on what needs to be done in which area. Inside or outside the container or inside or outside of the app. I try to keep good notes and have mental shortcuts for the things that I’ll use again. But just when I start to understand it, I’m done with what I need to do and I won’t touch it again for another 6 to 12 to 18 months. Then I have to kind of relearn it.
sounds like every system admin’s whole life story
my solution is to take notes then create a little how to here on meta
This is a How-To for other self hosted administrators
I self host on a virtual private server (debian)
I use docker-mailserver to provide an email server for my Discourse instance. It is a really easy solution for simple transactional email server for Discourse. It saves the emails in files on the server and doesn’t need a database. It is a no-frills solution without an online interface or any other amenities, just postfix, dovecot, fail2ban and ClamAV.
Here are the Docs
Renew LetsEncrypt Ce…
I make it a wiki so others can edit it if they find a mistake or oversight and next time I need to do this same thing…
1 Like