Hosting n8n on Google Cloud Run#
This hosting guide shows you how to self-host n8n on Google Cloud Run, a serverless container runtime. If you're just getting started with n8n and don't need a production-grade deployment, you can go with the "easy mode" option below for deployment. Otherwise, if you intend to use this n8n deployment at-scale, refer to the "durable mode" instructions further down.
If you want to deploy to Google Kubernetes Engine (GKE) instead, you can refer to these instructions.
Self-hosting knowledge prerequisites
Self-hosting n8n requires technical knowledge, including:
- Setting up and configuring servers and containers
- Managing application resources and scaling
- Securing servers and applications
- Configuring n8n
n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends n8n Cloud.
Latest and Next versions
n8n releases a new minor version most weeks. The latest
version is for production use. next
is the most recent release. You should treat next
as a beta: it may be unstable. To report issues, use the forum.
Current latest
: 1.114.3
Current next
: 1.115.0
Before you begin: get a Google Cloud project#
If you have not yet created a Google Cloud project, do this first (and ensure you have billing enabled on the project; even if your Cloud Run service runs for free you must have billing activated to deploy). Otherwise, navigate to the project where you want to deploy n8n.
Easy mode#
This is the fastest way to deploy n8n on Cloud Run. For this deployment, n8n's data is in-memory so this is only recommended for demo purposes. Anytime this Cloud Run service scales to zero or is redeployed, the n8n data will be lost. Refer to the durable mode instructions below if you need a production-grade deployment.
If you have not yet created a Google Cloud project, do this first (and ensure you have billing enabled on the project; even if your Cloud Run service will run for free you must have billing enabled to activated to deploy). Otherwise, navigate to the project where you want to deploy n8n.
Open the Cloud Shell Terminal (on the Google Cloud console, either type "G" then "S" or click on the terminal icon on the upper right).
Once your session is open, you may need to run this command first to login (and follow the steps it asks you to complete):
1 |
|
You can also explicitly enable the Cloud Run API (even if you don't do this, it will ask if you want this enabled when you deploy):
1 |
|
To deploy n8n:
1 2 3 4 5 6 7 |
|
(you can specify whichever region you prefer, instead of "us-west1")
Once the deployment finishes, open another tab to navigate to the Service URL. n8n may still be loading and you will see a "n8n is starting up. Please wait" message, but shortly thereafter you should see the n8n login screen.
Optional: If you want to keep this n8n service running for as long as possible to avoid data loss, you can also set manual scale to 1 to prevent it from autoscaling to 0.
1 2 3 4 5 6 7 8 |
|
This does not prevent data loss completely, such as whenever the Cloud Run service is re-deployed/updated. If you want truly persistant data, you should refer to the instructions below for how to attach a database.
Durable mode#
The following instructions are intended for a more durable, production-grade deployment of n8n on Cloud Run. It includes resources such as a database for persistance and secret manager for sensitive data.
Enable APIs and set env vars#
Open the Cloud Shell Terminal (on the Google Cloud console, either type "G" then "S" or click on the terminal icon on the upper right) and run these commands in the terminal session:
1 2 3 4 5 6 |
|
You'll also want to set some environment variables for the remainder of these instructions:
1 2 |
|
Setup your Postgres database#
Run this command to create the Postgres DB instance (it will take a few minutes to complete; also ensure you update the root-password field with your own desired password):
1 2 3 4 5 6 7 8 9 |
|
Once complete, you can add the database that n8n will use:
1 |
|
Create the DB user for n8n (change the password value, of course):
1 2 3 |
|
You can save the password you set for this n8n-user to a file for the next step of saving the password in Secret Manager. Be sure to delete this file later.
Store sensitive data in Secret Manager#
While not required, it's absolutely recommended to store your sensitive data in Secrets Manager.
Create a secret for the database password (replace "/your/password/file" with the file you created above for the n8n-user password):
1 2 3 |
|
Create an encryption key (you can use your own, this example generates a random one):
1 |
|
Create a secret for this encryption key (replace "my-encryption-key" if you are supplying your own):
1 2 3 |
|
Now you can delete my-encryption-key and the database password files you created. These values are now securely stored in Secret Manager.
Create a service account for Cloud Run#
You want this Cloud Run service to be restricted to access only the resources it needs. The following commands create the service account and adds the permissions necessary to access secrets and the database:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Deploy the Cloud Run service#
Now you can deploy your n8n service:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Once the deployment finishes, open another tab to navigate to the Service URL. You should see the n8n login screen.