In short
- rAthena asks for at least 1 core, 1 GB of memory and 300 MB of disk, and recommends 2 cores and 2 GB. It runs on Linux with gcc 6 or newer and needs MySQL or MariaDB.
- On Ubuntu 24.04 or Debian 12 the whole build is one apt line, a git clone, ./configure and make server. Pick renewal or pre-renewal, and the packet version of your client, at configure time.
- Import main.sql, web.sql and roulette_default_data.sql into one database and logs.sql into a second, then give rAthena its own database user instead of the ragnarok login it ships with.
- Put every change in conf/import/, change the s1 and p1 inter-server login, and set char_ip and map_ip to the server's public address, or players drop after the login screen.
- Open TCP 6900, 6121 and 5121 to players, and 8888 if your client uses the web server. The database stays on localhost.
On this page
- What you need before you start
- Install the build tools and MariaDB
- Build rAthena as its own user
- Create the database and load the tables
- Tell rAthena who it is
- Open the four ports, and only those
- Start the servers and keep them running
- Make an account and log in
- When the first login fails
- Keeping it up to date
- If you run Hercules instead
- Questions
- Sources
rAthena's own install pages were written for Ubuntu 18.04 and Debian 10, and some of the package names in them have changed since.23 The steps themselves have barely moved: install a compiler and a database, build rAthena, load its tables, tell it who it is, and open four ports. What costs people is skipping the boring parts. The default inter-server password and database login are published with the source, so a server that still uses them is open to anyone who has read it.
This guide takes a fresh Ubuntu 24.04 or Debian 12 server to the first login, one step at a time, with every command taken from rAthena's own wiki. Hercules is close enough that the differences fit in a short note at the end of each section. Security beyond the basics, including the 2025 advisories, has a guide of its own.
What you need before you start
rAthena's README sets the floor: one core, 1 GB of memory and 300 MB of disk at minimum, two cores, 2 GB and 500 MB recommended.1 On Linux it wants gcc 6 or newer and Make; on Windows, Visual Studio 2017 or newer. The database is MySQL or MariaDB, version 5 or newer, and you need git to fetch and update the source. The README gives no figure per player, and nobody else can honestly give you one either: a busy map with custom scripts and a database on the same machine is a different load from a quiet test server.
| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 1 core | 2 cores |
| Memory | 1 GB | 2 GB |
| Disk | 300 MB | 500 MB |
The README's own figures. rAthena publishes no per-player sizing.
Treat the recommended figures as the start, not the ceiling. The three game servers, MariaDB and the web server all share the machine, and MariaDB is happiest with memory to spare. You also need a client that matches the server's packet version, which you supply yourself; this guide does not cover building or distributing one.
Install the build tools and MariaDB
The rAthena wiki's Ubuntu page installs build-essential, zlib1g-dev and libpcre3-dev, then MariaDB's client headers as libmariadb-dev and libmariadb-dev-compat.2 The Debian page lists the same libraries under older package names.3 All five packages exist under these names in Debian 12 and Ubuntu 24.04,2021 so one line installs everything, with git and the MariaDB server added:
sudo apt update && sudo apt upgradesudo apt install build-essential git zlib1g-dev libpcre3-dev mariadb-server libmariadb-dev libmariadb-dev-compatThen run MariaDB's own hardening script, which the wiki also asks for, and answer each of its prompts; on a server that only rAthena uses, the stricter answer is the right one every time.2
sudo mysql_secure_installationBuild rAthena as its own user
Never build or run the emulator as root. The wiki creates a user called rathena for the job;2 it does not need sudo once the packages are in. A bug in a game server that runs as an ordinary user can damage that user's files. The same bug running as root owns the machine. For the rest of the server's first hour, from SSH keys to automatic updates, see securing a new Linux server.
sudo adduser rathenasudo -iu rathenagit clone https://github.com/rathena/rathena.git ~/rathenacd ~/rathena./configure --enable-epoll=yes --enable-prere=nomake clean && make serverTwo choices are made at ./configure time, and changing either later means building again.
- Renewal or pre-renewal. rAthena builds renewal by default;
--enable-prere=yesbuilds pre-renewal.8 Match it to the server you are making. - Packet version. The server must speak the same protocol version as your client. The default is
20211103, and you can change it with--enable-packetver=followed by your client's date in the form YYYYMMDD.9 A mismatch shows up as clients that connect and then fail in odd ways, not as a clean error.
When make server finishes, the folder holds login-server, char-server, map-server and web-server.3
Create the database and load the tables
rAthena's SQL readme is specific about a new install: main.sql, web.sql and roulette_default_data.sql go into the main schema, and logs.sql can go there too but is "highly suggested" to get a schema of its own.6 Give rAthena a database user of its own as well. The wiki is blunt that it should never be root.4
sudo mysql -e "CREATE DATABASE ragnarok; CREATE DATABASE ragnarok_log;"sudo mysql -e "CREATE USER 'rathena'@'localhost' IDENTIFIED BY 'a-long-random-password';"sudo mysql -e "GRANT ALL ON ragnarok.* TO 'rathena'@'localhost'; GRANT ALL ON ragnarok_log.* TO 'rathena'@'localhost';"cd /home/rathena/rathena/sql-filesmysql -u rathena -p ragnarok < main.sqlmysql -u rathena -p ragnarok < web.sqlmysql -u rathena -p ragnarok < roulette_default_data.sqlmysql -u rathena -p ragnarok_log < logs.sqlThe user is created for localhost only, so it cannot log in from anywhere else even if port 3306 were open. Keep it that way: nothing outside the server ever needs to reach the database. The item and monster tables for renewal or pre-renewal are only needed if you turn on use_sql_db, and then only the set that matches the mode you built.6
Tell rAthena who it is
Every setting below goes in conf/import/, not in the main conf files. rAthena reads each conf file and then its import file, and the import file's lines take priority; the import folder is never overwritten when you update, so your changes survive every git pull.4
The database login
Out of the box, inter_athena.conf points every server at a database on 127.0.0.1 port 3306 with the user ragnarok and the password ragnarok.14 In conf/import/inter_conf.txt, set the _id, _pw and _db lines for the login, ipban, char, map and web connections to your own user and the ragnarok database, and the log_db_ lines to ragnarok_log.
The inter-server login
The character and map servers sign in to each other with userid: s1 and passwd: p1 in the stock files,1213 and main.sql creates account 1 with exactly that pair.7 The wiki says they must be changed, and must match in three places: the char conf, the map conf and that row of the login table.4
sudo mysql ragnarok -e "UPDATE login SET userid = 'your-own-id', user_pass = 'a-long-random-one' WHERE account_id = 1;"Then put the same pair in both import files:
userid: your-own-idpasswd: a-long-random-oneThe public address
This is the step that breaks most first servers. A Ragnarok login is three connections, not one. The login server checks the password and then tells the client where the character server is; the character server tells it where the map server is. The comment above char_ip says it plainly: "Set this to what your server's public IP address is", and map_ip carries the same line.1213
If char_ip is 127.0.0.1 or a private address, the password is accepted, the client is sent to an address on its own side of the internet, and the player drops back to the login screen. The wiki notes that rAthena tries to detect the address when the lines are commented out, but its advice is that char_ip and map_ip are always the public address, with no exceptions.4With a server at the documentation address 203.0.113.10, the import files get:
server_name: YourServerchar_ip: 203.0.113.10map_ip: 203.0.113.10The login_ip and the map server's own char_ip are where the servers find each other. On one machine that is 127.0.0.1, which is what you want: their inter-server traffic never leaves the box.4 Do not use spaces in server_name, or guild emblems break on the client.4
Open the four ports, and only those
Every rAthena server listens on TCP: the socket code opens stream sockets throughout.10 The stock ports are 6900 for login,11 6121 for the character server12 and 5121 for the map server,13 and the web server listens on 8888.15 The login conf turns on web authentication tokens, which it says are required for new clients that fetch data over HTTP;11 with an older client, 8888 can stay closed. Port 3306 is never opened. For why each kind of port exists and how firewalls treat them, see game server ports and firewalls.
sudo ufw allow OpenSSHsudo ufw allow 6900/tcpsudo ufw allow 6121/tcpsudo ufw allow 5121/tcp8888 is only for the optional web server. Uncomment it only if your client uses it.$ sudo ufw allow 8888/tcpsudo ufw enableName the protocol on every rule: in ufw, a rule without one opens TCP and UDP both.22 Allow SSH before you enable the firewall, or the session you are typing in can be the first thing it drops. If your host has a network firewall in front of the server as well, the same four ports need a rule there.
Start the servers and keep them running
rAthena ships athena-start, which starts, stops and restarts all of its servers and keeps their process IDs in the folder.163 Run it as the rathena user from the rAthena folder:
cd ~/rathena./athena-start start./athena-start stopThat is enough for a test server. For one people rely on, give each server a systemd unit so it starts on boot and comes back after a crash. A unit with Restart=on-failure restarts the process when it exits with an error or is killed by a signal.23 The login server's unit looks like this; the character, map and web servers get the same file with their own binary:
[Unit]Description=rAthena login serverAfter=network.target mariadb.service[Service]User=rathenaWorkingDirectory=/home/rathena/rathenaExecStart=/home/rathena/rathena/login-serverRestart=on-failure[Install]WantedBy=multi-user.targetMake an account and log in
The stock login conf has new_account: no, so the old trick of registering by adding _M or _F to a username is off.11 Create your first account in the database instead. The login table numbers player accounts from 2000000,7 and the wiki's SQL guide gives an account full GM rights with group 99:5
sudo mysql ragnarok -e "INSERT INTO login (userid, user_pass, sex, email, group_id) VALUES ('yourname', 'a-long-password', 'M', 'you@example.com', 99);"Point your client at the server's public address on port 6900 and log in. If you reach character select and then drop, go back to char_ip. If you reach a map, the server works; now make it safe to share.
Patch
Check the build against the four 2025 advisories before the address goes anywhere public.
Back up
Dump both databases every day to somewhere off the server, and restore one to prove it works.
Announce
Only once the firewall, the new logins and the backups are in place.
The rAthena hardening guide covers the patch check, the ddos settings and what to watch on opening day, and server backups covers the dumps.
When the first login fails
rAthena's README gives one piece of troubleshooting advice first: read the consoles, because most problems announce themselves there.1 Where the message is not obvious, the symptom usually points at one setting.
| What you see | Usual cause | Check |
|---|---|---|
| The client cannot reach the login server at all | Port 6900 closed in a firewall, or the login server not running | ss -lnt on the server, then the firewall rules |
| Character select appears, then the client drops | char_ip or map_ip is not the public address | The two import files |
| The character server says it cannot log in to the login server | The s1 and p1 replacement differs between a conf file and the login table | All three places hold the same pair |
| A server stops at start with a database error | The user, password or database name in inter_conf.txt does not match MariaDB | Log in with mysql -u rathena -p ragnarok by hand |
| Clients connect, then fail on odd packets | The packet version does not match the client | Rebuild with the client's date in --enable-packetver= |
Keeping it up to date
Updating is a git pull followed by the same build.3 Because every change you made lives in conf/import/, the pull does not fight with your settings, and the import folder is left alone.4 Stop the servers, pull, rebuild, start them again:
cd ~/rathena./athena-start stopgit pull./configure --enable-epoll=yes --enable-prere=no && make clean && make server./athena-start startPass the same ./configure options you built with the first time, or the update quietly switches the server's mode. Some updates also change the database: the sql-files/upgrades folder holds the scripts for that, and the SQL readme says the import files are needed for later updates as well as for new installs.6 Take a database dump before every update, so a bad one is a restore and not a rebuild.
If you run Hercules instead
Hercules keeps the same shape with different file names. Its character server listens on 6121 and logs in to the login server on 6900, its map server listens on 5121, and both ship with userid: "s1" and passwd: "p1".1718 The database connection lives in conf/global/sql_connection.conf, with the same ragnarok user, password and database by default.19 Change the same things, in those files, and open the same three game ports.
Questions
Can I run rAthena on Windows?
Yes. The README lists Visual Studio 2017 or newer as the compiler on Windows, and the wiki has a Windows installation page. This guide covers Linux, which is what most hosted servers run.
Should I build renewal or pre-renewal?
Whichever your server is meant to be. rAthena builds renewal unless you pass --enable-prere=yes to ./configure, and the choice is made at build time, so rebuild if you change your mind.
Why do players get disconnected right after the login screen?
Almost always because char_ip or map_ip points at an address the player cannot reach, such as 127.0.0.1 or a private address. The login server tells the client where the character server is, and the character server tells it where the map server is, so both must be the server's public address.
Do I need port 8888?
Only if your client uses rAthena's web server. The login server has the web token system turned on because newer clients fetch some data over HTTP; older clients never connect to 8888, and then you can leave it closed.
Is this the same on Hercules?
Mostly. Hercules uses the same login, character and map ports, ships the same s1 and p1 inter-server login and the same ragnarok database login, and keeps its settings in conf/login, conf/char and conf/map instead of the *_athena.conf files.
Sources
- rAthena READMErAthena on GitHub
- Basic Ubuntu installation guiderAthena wiki
- Install on DebianrAthena wiki
- ConnectingrAthena wiki
- SQL installationrAthena wiki
- SQL imports (sql-files/README.md)rAthena on GitHub
- sql-files/main.sqlrAthena on GitHub
- configure.acrAthena on GitHub
- src/config/packets.hpprAthena on GitHub
- src/common/socket.cpprAthena on GitHub
- conf/login_athena.confrAthena on GitHub
- conf/char_athena.confrAthena on GitHub
- conf/map_athena.confrAthena on GitHub
- conf/inter_athena.confrAthena on GitHub
- conf/web_athena.confrAthena on GitHub
- athena-startrAthena on GitHub
- conf/char/char-server.conf (stable)Hercules on GitHub
- conf/map/map-server.conf (stable)Hercules on GitHub
- conf/global/sql_connection.conf (stable)Hercules on GitHub
- Package libmariadb-dev in bookwormDebian
- Package libmariadb-dev in nobleUbuntu
- ufw(8), Debian bookworm manpagesDebian
- systemd.servicefreedesktop.org