Local Development

Install build requirements

Install the latest Rust version using rustup.

Debian-based distro:

sudo apt install git cargo libssl-dev pkg-config libpq-dev curl
# install yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn

Arch-based distro:

sudo pacman -S git cargo openssl pkg-config postgresql-libs curl yarn


Install Homebrew if you don't already have it installed. Then install Node and Yarn.

brew install node yarn

Setup PostgreSQL database

Debian-based distro:

sudo apt install postgresql
sudo systemctl start postgresql

Arch-based distro:

sudo pacman -S postgresql
sudo systemctl start postgresql
# If the systemctl command errors, then run the following
sudo mkdir /var/lib/postgres/data
sudo chown postgres:postgres /var/lib/postgres/data
sudo -u postgres initdb -D /var/lib/postgres/data
sudo systemctl start postgresql


brew install postgresql
brew services start postgresql
$(brew --prefix postgresql)/bin/createuser -s postgres

Either execute scripts/db-init.sh, or manually initialize the postgres database:

psql -c "create user lemmy with password 'password' superuser;" -U postgres
psql -c 'create database lemmy with owner lemmy;' -U postgres
export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy

Get the code

Clone frontend and backend code to local folders. Be sure to include --recursive to initialize git submodules.

git clone https://github.com/LemmyNet/lemmy.git --recursive
git clone https://github.com/LemmyNet/lemmy-ui.git --recursive

Backend development

Use cargo check to find compilation errors. To start the Lemmy backend, run cargo run. It will bind to

After making changes, you need to format the code with cargo +nightly fmt --all and run the linter with ./scripts/lint.sh.

Frontend development

Install dependencies by running yarn. Then run yarn dev to launch lemmy-ui locally. It automatically connects to the Lemmy backend on localhost:8536. Open localhost:1234 in your browser. The project is rebuilt automatically when you change any files.

Note that this setup doesn't support image uploads. If you want to test those, you need to use the Docker development.


Run Rust unit tests:


To run federation/API tests, first add the following lines to /etc/hosts:       lemmy-alpha       lemmy-beta       lemmy-gamma       lemmy-delta       lemmy-epsilon

Then run the following script:

cd api_tests