Setting up n8n for Google Sheets
I use n8n for small automation jobs. Google Sheets is one of the easier targets, and one of the easier things to get wrong if you skip the checks.
Getting n8n ready
What n8n and Google Sheets are doing here
n8n is a node-based automation tool. You wire nodes together and pass data between them. Google Sheets can sit at either end of that flow: read rows, append new ones, or update cells from another service. For light work, a sheet can act as a quick datastore. For anything heavier, Postgres is the better choice.
You can connect n8n to Google Sheets with OAuth or a Google service account. OAuth is fine when n8n is user-facing or running in n8n Cloud. For self-hosted n8n, a service account with a JSON key is usually the cleaner option.
What you need first
- A server or container host for n8n. I use Docker Compose on an Ubuntu VM.
- A current n8n release. I usually stay within the last six months.
- A Google account with access to the sheet you want to use.
- For a service account: a Google Cloud project, a service account JSON key, and the sheet shared to the service account email address.
- A Postgres database for production. SQLite is fine for tests.
Check the network path too. Webhook triggers need a reachable HTTPS endpoint. If the host sits behind NAT, use a tunnel like ngrok or put n8n behind a reverse proxy with valid TLS.
Basic setup
-
Install n8n.
- With Docker Compose, use the official image.
- Typical settings include:
N8N_PORT=5678 N8N_PROTOCOL=https N8N_HOST=your.domain.tld DB_TYPE=postgresStart the container and watch the logs.
docker compose up -d docker compose logs -f n8n -
Add authentication.
- Turn on basic auth for the editor with
N8N_BASIC_AUTH_ACTIVE=true, plus a username and password. - If n8n is exposed to the internet, put it behind a reverse proxy with TLS.
- Turn on basic auth for the editor with
-
Set up Google Sheets credentials.
- OAuth: create OAuth credentials in Google Cloud Console, then enter the client ID and secret in the n8n credentials UI.
- Service account: download the JSON key, create a Google Sheets credential in n8n, and share the sheet with the service account email.
- Test it with a simple workflow that reads the first row. Run it manually. If data comes back, the credential works.
-
Build a basic workflow.
- A simple pattern is Webhook trigger → HTTP Request node → Google Sheets node for append.
- Save the workflow and activate it.
- Fire the webhook URL from curl or Postman and check the sheet for a new row.
-
Keep secrets out of sight.
- Do not put keys in version control.
- Use a secret manager, or a docker-compose environment file with restricted permissions.
- For Postgres, set
DB_POSTGRESDB_DATABASE,DB_POSTGRESDB_USER,DB_POSTGRESDB_PASSWORD, andDB_POSTGRESDB_HOST.
-
Backups and monitoring.
- Send logs to a file or syslog and rotate them.
- Back up the database regularly. For Postgres, nightly dumps are a sensible baseline.
- Use container health checks and restart on failure.
After changing credentials, run a tiny workflow that reads one cell. If it fails, look at the credential error first.
After switching databases, check that workflow executions still appear and the old records are still there.
A simple webhook setup is usually enough: receive JSON and append it to a sheet.
- Create an HTTP or Webhook node and copy the URL.
- Add a Google Sheets node and set the operation to append.
- Map fields from the webhook body to the sheet columns.
- Run it with curl:
curl -X POST <url> -H 'Content-Type: application/json' -d '{"name":"Jane","email":"jane@example.com"}'
- Check the sheet for the new row.
Troubleshooting n8n problems
Start with the logs
If a node fails, open the execution details in the editor and check the node error. If the editor itself will not load, check the container logs.
- Credential errors: look for invalid credentials, permission denied, or 401/403 responses from Google. Check that the sheet is shared and the OAuth redirect URIs match.
- Webhook unreachable: look for connection refused or TLS handshake errors. Check
N8N_HOSTandWEBHOOK_URL. - Database errors: look for connection refused, authentication failures, or schema errors. Check the database variables and confirm the database accepts remote connections.
Useful places to check:
docker compose logs -f n8ndocker exec -it <n8n_container> bashand inspect/home/node/.n8n- For Postgres:
sudo -u postgres psql -c '\l'and check connectivity from the host
If Google returns 403, check three things: the service account has access to the sheet, the OAuth scopes are correct, and the credential has been reauthorised if needed.
Workflow management problems
Big workflows fail in awkward ways. Keep them small and test with sample data.
- Split large workflows into stages. Use webhooks and queues between them so one failure does not stall everything else.
- Use the Execute Workflow node to call other workflows. It keeps the main flow readable.
- Use SplitInBatches for bulk work. Fifty rows per batch is a decent place to start if timeouts are a problem.
- Set retry logic and backoff where the node allows it. Use a separate error workflow to log failures to a sheet or database.
If workflows hang or time out, increase the node timeout in settings or move the heavy work outside n8n and call it over HTTP.
For visibility, add a simple logging step at key points. Post execution details to a logging endpoint, or append minimal records to a dedicated Google Sheet for audit.
Where to look when you are stuck
The official docs, the n8n forum, GitHub issues, and community channels usually have the answer somewhere. The docs cover credential setup and node references, and forums tend to surface the real-world fixes.
When asking for help, include the n8n version, the deployment method, a screenshot of the node error and execution input, redacted environment variables, and a minimal workflow that reproduces the fault.
I usually paste the node input and the error message when I ask for help. It saves time.
Final takeaways
- Test every credential with a minimal workflow.
- Keep workflows small and visible.
- Back up the database and treat Postgres as production storage.
- Use a service account for predictable Google Sheets access on self-hosted n8n.




