LIVEReading: Run PostHog Analytics on Your Own Server in MinutesTotal time: 8 minSteps: 5Worked first time: 72% LIVEReading: Run PostHog Analytics on Your Own Server in MinutesTotal time: 8 minSteps: 5Worked first time: 72%
CBW
Run PostHog Analytics on Your Own Server in Minutes
Mediumgithub.com/PostHog/posthog2026-07-21

Run PostHog Analytics on Your Own Server in Minutes

PostHog is an open-source product analytics platform with session replay, feature flags, surveys, and more. This guide gets the self-hosted hobby version running on a Linux server with one command.

// Build stats

  • Total time8 min
  • Number of steps5
  • DifficultyMedium
  • Worked first time72%
// Before you start

What you need

  • A Linux server or VPS with at least 4 GB RAM (Ubuntu 22.04 recommended)
  • Docker installed on that server
  • A domain name or public IP address to reach the server
  • SSH access to the server
  • Ports 80 and 443 open in your firewall
01
Step 1 of 5

Connect to your server via SSH

2 min

You need to be logged into your Linux server to run commands. Open a terminal on your computer and connect using SSH. Replace 'your-server-ip' with the actual IP address of your server and 'your-username' with your login name (often 'ubuntu' or 'root' on cloud VPS providers).

Terminal · mac
$ ssh your-username@your-server-ip
What you should see
A command prompt showing your server's hostname, like: ubuntu@my-server:~$
This might happen

Permission denied or connection refused

Check that your SSH key or password is correct, and that port 22 is open in your server's firewall or security group settings.

02
Step 2 of 5

Confirm Docker is installed

1 min

PostHog's installer requires Docker. Run this command to check if Docker is already on your server. If it is not installed, visit docs.docker.com/engine/install/ubuntu/ and follow the official steps before continuing.

Terminal · mac
$ docker --version
What you should see
Something like: Docker version 24.0.5, build ced0996
This might happen

Command not found

Docker is not installed. Run: curl -fsSL https://get.docker.com | sh — then log out and back in so your user has Docker permissions.

03
Step 3 of 5

Run the PostHog one-line installer

10 min

This single command downloads and runs PostHog's official setup script. It will pull all the required Docker containers, ask you a few questions (like your hostname), and configure everything automatically. Keep an eye on the output — it will prompt you to enter your server's domain name or IP address during the process.

Terminal · mac
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/posthog/posthog/HEAD/bin/deploy-hobby)"
What you should see
The script prints progress messages as it pulls containers. Near the end you will see something like: PostHog is now running at http://your-server-ip or https://your-domain.com
This might happen

Script hangs or containers fail to start

Your server may not have enough memory. Confirm you have at least 4 GB RAM with: free -h — and that no other heavy processes are running. Try rebooting the server and running the command again.

04
Step 4 of 5

Open PostHog in your browser and create your account

3 min

Once the installer finishes, open a web browser and go to your server's IP address or domain name. PostHog will show you a setup screen to create your first admin account. Fill in your name, email, and a strong password. This becomes your login for everything.

Terminal · mac
$ http://your-server-ip
What you should see
A PostHog welcome screen asking you to create an account with fields for name, email, and password.
This might happen

Page does not load or shows a connection error

Wait another minute — containers can take time to fully start. Also confirm port 80 is open in your server firewall. Run: sudo docker ps — to check all containers show a status of 'Up'.

05
Step 5 of 5

Add the PostHog tracking snippet to your website

5 min

After logging in, PostHog will walk you through adding a small JavaScript snippet to your website. Copy the snippet it provides and paste it into the <head> section of your website's HTML. If you use a platform like WordPress, Webflow, or Squarespace, paste it in the 'custom code' or 'header scripts' section of your site settings. Once added, visit your website and then return to PostHog — you should see your first event appear within a minute.

Terminal · mac
$ <!-- Paste the snippet PostHog shows you during onboarding into your site's <head> tag. It looks like this: -->
$ <!-- !-- BEGIN POSTHOG -->
$ <script>
$ !function(t,e){...}(window, document)
$ </script>
$ <!-- END POSTHOG -->
What you should see
In the PostHog dashboard under 'Live Events', you will see events appearing as you browse your website.
This might happen

No events appear after adding the snippet

Check that the snippet is inside the <head> tag and that your browser is not blocking scripts with an ad blocker. Try opening your site in a private/incognito window.

// Status

cooked. baked. worked.

A fully running PostHog instance on your own server, accessible in a browser, with product analytics, session replay, feature flags, and more — ready to track events from any website or app you point at it.

// the honest bit

The honest part

The self-hosted hobby deployment is designed for small-scale use — roughly up to 100,000 events per month. PostHog does not offer customer support for self-hosted open-source deployments. For anything production-critical or higher volume, PostHog Cloud (posthog.com) is the more reliable choice and has a generous free tier. Keeping your self-hosted instance updated also requires manual effort. The installer script handles initial setup well, but upgrades are your responsibility.