Create a Server with Hetzner

Hetzner is a German-based company with data centers in the EU and the US. Their pricing is very competitive and they have incredible performance.

Create an account

The first step is to create an account with Hetzner. You can do this by going to their website and clicking the "Sign Up" button. With the link below, they offer €⁠20 (~$21 USD) credits free which can get you a server for a few months. This is an affiliate link, meaning we get a small kickback if you sign up, but this doesn't affect our recommendations.

Sign Up with Hetzner →

Create an API token

To create an API token, you'll need to sign in to the Hetzner Cloud Console. Once signed in, select your project.

Select Hetzner Project

Inside of the project, look for the "Security" page on the left, then click "API Tokens" at the top.

Hetzner API Tokens

When you click "Generate API Token", you'll be presented with the option to select the scopes for the token. Select "Read & Write".

Hetzner API Token Scopes

Place the token in your .spin.yml file

In your .spin.yml file, you'll find a providers section where you can add your Hetzner API token.

.spin.yml configure providers

##############################################################
# 👇 Providers - You must set at least one provider
##############################################################

providers:
  - name: hetzner
    api_token: abc123def456ghi789jkl012mno345pqr678stu901vwx234yz

Set as HCLOUD_TOKEN environment variable

If you prefer to set the token as an environment variable, you can also set the HCLOUD_TOKEN variable in your .env file, secrets manager, or wherever you store your environment variables.

Configure users

Make sure you configure your system users in your .spin.yml file.

Learn more about users →

Example users configuration in .spin.yml

##############################################################
# 👇 Users - You must set at least one user
##############################################################

users:
  - username: alice
    name: Alice Smith
    groups: ['sudo']
    authorized_keys:
      - public_key: "ssh-ed25519 AAAAC3NzaC1lmyfakeublickeyMVIzwQXBzxxD9b8Erd1FKVvu alice"

Configuring a Hetzner hardware profile

By default we set you up with a very cost-effective hardware profile to get up and running quickly.

.spin.yml default Hardware Profiles

##############################################################
# 🤖 Hardware Profiles
##############################################################

hardware_profiles:
  # Hetzner
  - name: hetzner_2c_2gb_ubuntu2404
    provider: hetzner
    profile_config:
      location: ash
      server_type: cpx11
      image: ubuntu-24.04
      backups: true

You can uncomment the defaults we give you or create/modify your own hardware profile.

Profile ConfigDescriptionAPI Reference
locationThe data center and location you want to deploy your server to (pick the closest one to your customers).See below for common examples.
server_typeThe type of server.See below for common examples.
imageThe image to use for the server.Hetzner Images
backupsWhether to enable snapshot backups for the server (may add 20% to the monthly price).Learn more about Hetzner snapshot backups.

Common Location Values

The location value is the name of the location. You can find the full list of locations here.

LocationCountryValue
FalkensteinGermanyfsn1
NurembergGermanynbg1
HelsinkiFinlandhel1
Ashburn, VAUSAash
Hillsboro, ORUSAhil
SingaporeSingaporesin

Common Server Types

You can find the full list of server types here.

Server TypevCPUsRAMStorageTrafficMonthly Price (in EUR)
Shared CPU - AMD (CPX)
cpx1122GB40GB1TB€4.99
cpx2134GB80GB2TB€9.49
cpx3148GB160GB3TB€16.49
cpx41816GB240GB4TB€30.49
cpx511632GB360GB5TB€60.49
Dedicated CPU (CCX)
ccx1328GB80GB1TB€12.99
ccx23416GB160GB2TB€25.99
ccx33832GB240GB3TB€49.99
ccx431664GB360GB4TB€99.99
ccx5332128GB600GB6TB€199.99

Configure your server

By default, we give you defaults to get up and running quickly, but you might want to make some changes.

Learn more about server configuration →

Example server configuration in .spin.yml

##############################################################
# 👇 Servers - You must set at least one server
##############################################################

servers:
  - server_name: ubuntu-2gb-ash-1
    environment: production
    hardware_profile: hetzner_2c_2gb_ubuntu2404

Provision your server

Once you have everything ready, you can provision your server(s) by running this simple command:

Provision your server(s)

spin provision

This command will create your server(s) with Hetzner and configure your server(s) to be ready for deployment. There are many more options available when provisioning your server(s). To learn more see the guide below:

Learn more about "spin provision" →

Getting ready for deployment

Now that you have a server ready, you'll want to learn how to get ready for deployment. Next steps are to choose a deployment strategy.

Learn which deployment strategy is right for you →