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.
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.
Inside of the project, look for the "Security" page on the left, then click "API Tokens" at the top.
When you click "Generate API Token", you'll be presented with the option to select the scopes for the token. Select "Read & Write".
This API token is very powerful and should be treated as a secret. Do not share this token and treat it like you would a password.
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.
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 Config | Description | API Reference |
---|---|---|
location | The data center and location you want to deploy your server to (pick the closest one to your customers). | See below for common examples. |
server_type | The type of server. | See below for common examples. |
image | The image to use for the server. | Hetzner Images |
backups | Whether 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.
Location | Country | Value |
---|---|---|
Falkenstein | Germany | fsn1 |
Nuremberg | Germany | nbg1 |
Helsinki | Finland | hel1 |
Ashburn, VA | USA | ash |
Hillsboro, OR | USA | hil |
Singapore | Singapore | sin |
Common Server Types
Make sure your server type is supported in the location you choose. Also, some of the pricing may change so be sure to check the latest pricing on the Hetzner Cloud Pricing Page.
You can find the full list of server types here.
Server Type | vCPUs | RAM | Storage | Traffic | Monthly Price (in EUR) |
---|---|---|---|---|---|
Shared CPU - AMD (CPX) | |||||
cpx11 | 2 | 2GB | 40GB | 1TB | €4.99 |
cpx21 | 3 | 4GB | 80GB | 2TB | €9.49 |
cpx31 | 4 | 8GB | 160GB | 3TB | €16.49 |
cpx41 | 8 | 16GB | 240GB | 4TB | €30.49 |
cpx51 | 16 | 32GB | 360GB | 5TB | €60.49 |
Dedicated CPU (CCX) | |||||
ccx13 | 2 | 8GB | 80GB | 1TB | €12.99 |
ccx23 | 4 | 16GB | 160GB | 2TB | €25.99 |
ccx33 | 8 | 32GB | 240GB | 3TB | €49.99 |
ccx43 | 16 | 64GB | 360GB | 4TB | €99.99 |
ccx53 | 32 | 128GB | 600GB | 6TB | €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.