SyntaxLabs Documentation
Sign in
On this page

Installation

This guide covers installing CodeLock on your own server.

Requirements

  • Node.js 24.15.0
  • MySQL 5.7+ or MariaDB 10.3+
  • A Discord application, used for logging in
  • A valid CodeLock licence key
  • Outbound HTTPS access to syntaxlabs.co.uk, used for licence checks

1. Download and install dependencies

Extract CodeLock into a folder on your server, then install its dependencies:

cd codelock
npm install

2. Create the database

Create an empty database, then import the included install.sql:

mysql -u root -p -e "CREATE DATABASE codelock CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
mysql -u root -p codelock < install.sql

You can also import install.sql with phpMyAdmin, HeidiSQL or a similar tool.

3. Create a Discord application

  1. Go to the Discord Developer Portal and click New Application.

  2. Open OAuth2 and copy the Client ID and Client Secret.

  3. Under Redirects, add your callback URL:

    https://your-domain.com/auth/discord/callback
    

    If you’re running locally, use http://localhost:3000/auth/discord/callback.

The redirect URL must exactly match your Domain setting plus /auth/discord/callback.

4. Configure CodeLock

Open config.js and fill in your details:

module.exports = {
  Site: {
    Domain: "https://your-domain.com",   // Public URL, no trailing slash
    Port: 3000,                          // Port CodeLock listens on
    Admins: ["123456789012345678"],      // Discord user IDs with full admin access
    Secret: 'a-long-random-string',      // Session secret, keep this private
    MaxUploadMB: 100,                    // Max upload size per file
    TrustProxy: 0,                       // Set to 1 if behind Nginx/Cloudflare/etc.
    Ignore: ['config.js', 'index.js', 'src/static/js/'] // Paths inside ZIPs that won't be locked
  },
  Tokens: {
    OAuthDiscordID: "DISCORD_CLIENT_ID",
    OAuthDiscordSecret: "DISCORD_CLIENT_SECRET",
    LicenseKey: "YOUR_LICENSE_KEY",
  },
  SQL: {
    Host: "localhost",
    Port: 3306,
    Username: "codelock",
    Password: "your-db-password",
    Database: "codelock"
  }
}

Tips:

  • Finding your Discord ID: In Discord, open Settings → Advanced and turn on Developer Mode. Then right-click your name and choose Copy User ID.
  • Generating a secret: Run node -e "console.log(require('crypto').randomBytes(32).toString('hex'))".
  • Changing the secret later: Don’t change Secret after the first start. Changing it logs everyone out and resets the stored licence state.

5. Start CodeLock

npm start

When it starts successfully, you’ll see the CodeLock banner and:

[License]: License is valid.
[Server]: Server running on port 3000 is now loaded & Online

Open your domain in a browser and log in with Discord. Accounts listed in Admins get full access straight away.

Use a process manager so CodeLock restarts after crashes and reboots. For example, with PM2:

npm install -g pm2
pm2 start index.js --name codelock
pm2 save
pm2 startup

7. Reverse proxy (optional)

If you run CodeLock behind Nginx, Apache or Cloudflare, set TrustProxy: 1 in config.js. A minimal Nginx example:

server {
    server_name your-domain.com;
    client_max_body_size 100M;   # match MaxUploadMB

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Managing users

  • New users who log in have no access until an admin approves them.
  • Admins can grant or remove access on the Staff page.
  • Users listed in config.js → Admins always keep admin access and can’t be removed from the panel.

Troubleshooting

Problem Solution
License check did not pass Check that LicenseKey is correct and the licence is active for this domain.
License server unreachable Make sure the server can reach https://syntaxlabs.co.uk (check your firewall or outbound rules).
Discord says Invalid OAuth2 redirect_uri The redirect in the Discord Developer Portal must exactly match Domain + /auth/discord/callback.
ER_ACCESS_DENIED_ERROR / ECONNREFUSED Check the SQL settings and that MySQL is running.
ER_NO_SUCH_TABLE install.sql wasn’t imported. Import it into the database named in config.js.
Large uploads fail behind a proxy Raise client_max_body_size (Nginx) to match MaxUploadMB.
Logged in but see “No Access” An admin needs to approve your account, or add your Discord ID to Admins and log in again.
Written by Ollie Last updated 29 Nov 2026 3 min read