How to Connect Postgres to Looker in PostgreSQL

Galaxy Glossary

How do I securely connect a PostgreSQL database to Looker?

Securely expose your PostgreSQL database to Looker and grant the minimum permissions Looker needs to query data for dashboards.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Description

Table of Contents

Why connect PostgreSQL to Looker?

Connecting Looker to PostgreSQL lets analysts build self-serve dashboards while engineers keep full control of the database.Real-time data stays in Postgres; Looker only issues read-only SQL.

What are the prerequisites?

You need a reachable PostgreSQL instance (v9.6+) with SSL enabled, a Looker account with admin rights, and a database user that has SELECT access to the schemas you want to expose.

How do I create a read-only Postgres user for Looker?

Run CREATE ROLE looker_user LOGIN PASSWORD 'strongPW'; then grant connection and read rights with the syntax below.Limiting permissions avoids accidental data changes.

Which connection parameters does Looker require?

Looker needs host, port, database, username, password, SSL mode, and optional SSH tunnel info. Default port is 5432 and SSL Mode should be require or verify-full.

How do I whitelist Looker IPs?

Add Looker’s outbound IP ranges to your firewall or cloud-provider security group.Without whitelisting, the handshake will fail even if credentials are correct.

How do I add the connection inside Looker?

Navigate to Admin → Connections → New Connection, pick PostgreSQL, fill the fields, test, then save. Looker will inspect available schemas and start generating PDTs if enabled.

Can I limit Looker to specific schemas?

Yes—grant USAGE on the schemas you want (public, analytics) and REVOKE USAGE on the rest.Looker will only see tables in schemas it can access.

Best practices for production

Use SSL, rotate passwords regularly, monitor query load, and create dedicated replica endpoints to protect OLTP performance. Enable Statement Timeout to avoid runaway Looker queries.

.

Why How to Connect Postgres to Looker in PostgreSQL is important

How to Connect Postgres to Looker in PostgreSQL Example Usage


-- Looker will run queries like this
SELECT c.name,
       SUM(oi.quantity * p.price) AS lifetime_value
FROM Customers c
JOIN Orders o      ON o.customer_id = c.id
JOIN OrderItems oi ON oi.order_id   = o.id
JOIN Products p    ON p.id          = oi.product_id
GROUP BY c.name
ORDER BY lifetime_value DESC
LIMIT 100;

How to Connect Postgres to Looker in PostgreSQL Syntax


-- 1. Create read-only role for Looker
CREATE ROLE looker_user LOGIN PASSWORD 'S3curePa55';

-- 2. Grant minimal privileges
GRANT CONNECT ON DATABASE ecommerce TO looker_user;
GRANT USAGE ON SCHEMA public, analytics TO looker_user;
GRANT SELECT ON ALL TABLES IN SCHEMA public, analytics TO looker_user;
-- Future-proof the privilege
ALTER DEFAULT PRIVILEGES IN SCHEMA public, analytics
  GRANT SELECT ON TABLES TO looker_user;

-- 3. Connection string example
postgresql://looker_user:S3curePa55@reports.example.com:5432/ecommerce?sslmode=require

Common Mistakes

Frequently Asked Questions (FAQs)

Does Looker support PostgreSQL replicas?

Yes. Point the connection host to a read-replica endpoint to offload analytics workloads from your primary.

How do I refresh schema changes?

After altering tables, click "Rebuild PDTs and Cache" or run SELECT looker_refresh(); if you created a helper function.

Can I use SSH tunneling?

Absolutely. Provide the bastion host, port, user, and private key in Looker’s SSH section. Traffic will route through the tunnel before reaching Postgres.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.