│postgres=# \l │ │ List of databases │ │ Name | Owner | Encoding | Collate | Ctype | Access privileges │ │————-+———-+———-+————-+————-+———————– │ │ postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | │ │ supertokens | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | │ │ template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + │ │ | | | | | postgres=CTc/postgres │ │ template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + │ │ | | | | | postgres=CTc/postgres │ │(4 rows)
how can i look inside the databases with psql
Use \c <dbname>
to connect, then \dt
or \d
to inspect contents:
\c supertokens -- connect to the database
\dt -- list tables
\d tablename -- describe table schema
SELECT * FROM tablename LIMIT 10; -- peek into data
You can also:
\dn
for schemas\dv
for views\di
for indexesKeep it scoped—Postgres can get noisy fast.
look inside a table
Once connected (\c dbname
), do:
\d+ tablename -- show table schema with size, defaults, etc.
SELECT * FROM tablename LIMIT 10; -- show first 10 rows
Need specific columns?
SELECT id, email FROM users LIMIT 10;
Want structure and data inline?
SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'tablename';
Use \x
for expanded display if rows are wide.
all the select * queries return nothing
If SELECT * FROM tablename
returns no rows:
\dt -- list tables
SELECT COUNT(*) FROM tablename;
public
schema, but your table might be in another.\dn -- list schemas
SET search_path TO schema_name;
\c -- shows current database
\d+ tablename
Still stuck? Run:
SELECT * FROM information_schema.tables WHERE table_name = 'tablename';
If it returns nothing, the table doesn’t exist in that DB under your current search path.
no i am getting nothing it just goes back to psql prompt
Got it—if SELECT * FROM tablename;
gives no error, just returns to the prompt with no rows, that means:
Confirm with:
SELECT COUNT(*) FROM tablename;
If that returns 0
, it’s confirmed: no data.
You can check when rows were inserted (if tracked), or look at other tables:
\dt *.* -- list all tables in all schemas
Or check recent writes (if any):
SELECT relname, n_tup_ins, n_tup_upd, n_tup_del
FROM pg_stat_user_tables
ORDER BY n_tup_ins DESC
LIMIT 10;
If you’re expecting data—make sure you’re in the right environment (e.g., not your dev container with a fresh DB).
well this is a db connection over a kubectl port-forward
Ah—then suspicion shifts to environment mismatch or data not persisting.
Checklist:
kubectl get pods -n your-namespace
kubectl port-forward pod/your-postgres-pod 5432:5432 -n your-namespace
kubectl get pods -n your-namespace
kubectl exec -it pod/your-postgres-pod -n your-namespace -- psql -U postgres -d supertokens
Run SELECT *
from inside the pod. If data is missing there too—DB is empty. If data exists inside but not over the forwarded connection, it’s probably a misrouted forward.
SHOW config_file;
Check host/IP identity:
SELECT inet_server_addr(), inet_server_port();
Let me know what you find—can zero in fast once we confirm the target.
even from inside the pod, the queries yield precisely nothing
Then it’s almost certainly this: the DB was never seeded, or its volume is ephemeral and reset on pod restart.
To confirm:
kubectl get pod your-postgres-pod -n your-namespace -o wide
kubectl describe pod your-postgres-pod -n your-namespace | grep -i restart
If it’s restarted recently and no PersistentVolumeClaim
is attached, data’s gone.
kubectl get pvc -n your-namespace
Look for a bound volume for Postgres. No PVC? It’s running with emptyDir or no volume—so data resets every restart.
Check if there’s a init.sql
, docker-entrypoint-initdb.d
, or migration job that should seed data:
kubectl get deployments,statefulsets -n your-namespace
kubectl describe deployment your-postgres-deploy -n your-namespace
Also look for Helm values or kustomize overlays that might mount initial SQL.
No data inside the pod = it’s not about psql, it’s about Postgres not having been initialized or its data being wiped.
Want help tracing the PVC or volumeMount setup in your deployment?
earlier i was using metabase to connect, it was able to show me the data that was on there, and there was data in the tables, but now even metabase is erroring out
That’s the key detail. Previously Metabase saw real data, now nothing works. That points to one of three likely causes:
Postgres was using emptyDir
or local storage. Restart nuked all data.
Confirm with:
kubectl get pods -n your-namespace -o wide
kubectl describe pod your-postgres-pod -n your-namespace | grep -i restart
kubectl get pvc -n your-namespace
No bound PVC? Then yeah, it was ephemeral.
Maybe DNS/service changed, or port-forward is targeting a new pod (e.g. after redeploy).
Check:
kubectl get pods -n your-namespace -o wide
kubectl port-forward pod/EXACT-POD-NAME 5432:5432 -n your-namespace
Verify with:
SELECT current_database(), inet_server_addr();
Compare with previous values (if you noted them).
If Metabase is erroring out and psql
still works but shows zero rows, it may not be corruption—but it’s possible Postgres didn’t boot properly, and the DB is in a weird init state.
Check logs:
kubectl logs pod/your-postgres-pod -n your-namespace
Look for errors like:
database system was shut down
FATAL: could not open relation
PANIC: could not locate
Want to dig into your PVC config or deployment YAML? Can help you quickly trace if this DB is persistent or disposable.
kubectl get pods gives deployment-backend-b49ff867b-dztbq 1/1 Running 0 11h deployment-frontend-79786dff4f-k2rhf 1/1 Running 0 41h supertokens-core-5fb5dbf697-h79wl 1/1 Running 0 41h
and the psql port forward works with this command kubectl port-forward svc/stg-postgresql -n postgresql 5432:5432
That narrows it down—you’re not port-forwarding to a pod, you’re port-forwarding to a service (svc/stg-postgresql
) in the postgresql namespace. But your pod list shows no Postgres pod at all—and no pods in that namespace.
So what’s serving svc/stg-postgresql
? Likely nothing—the backing pod is gone, and Kubernetes is silently forwarding to nowhere.
kubectl get svc stg-postgresql -n postgresql -o yaml
Look for selector:
— it tells you what pods it’s supposed to route to.
kubectl get pods -n postgresql
I expect: nothing running. That would explain why Metabase errors and psql shows empty or no data—there’s no backing Postgres.
kubectl get deployments,statefulsets -n postgresql
If there’s no deployment or statefulset for Postgres, then:
kubectl get pvc -n postgresql
If PVCs exist but no pod is using them, your data might be safe and just needs a new pod reattached.
Bottom line:
Your service (stg-postgresql
) has no live backend. You’re connecting to a ghost.
Ready to help revive it or inspect its original deployment config.
Perfect—infra’s intact. You’re just port-forwarding incorrectly or to the wrong endpoint. Let’s connect to the real thing.
Services are stable, but only work if they have ready pods. Safer bet: forward directly to the pod behind stg-postgresql
.
kubectl get pods -n postgresql -l app=stg-postgresql
(Substitute app=stg-postgresql
with the actual label selector from your service.)
kubectl port-forward pod/ -n postgresql 5432:5432
psql -h localhost -U postgres -d your_db_name
If you’re already inside the cluster (e.g. in a debug pod or another service):
psql -h stg-postgresql.postgresql.svc.cluster.local -U postgres -d your_db_name
Confirm service resolves to pod IPs:
kubectl get endpoints stg-postgresql -n postgresql
If this shows no IPs, service is ghosting again. If it shows one or more IPs: all good—then your earlier port-forward may have been racing pod readiness.
Once connected directly, your data should show up as expected. Want help tracing readiness probes or PVC mount paths next?
once again there are no resources in the default or postgresql namespace, get pods gives this NAME READY STATUS RESTARTS AGE deployment-backend-b49ff867b-dztbq 1/1 Running 0 11h deployment-frontend-79786dff4f-k2rhf 1/1 Running 0 41h supertokens-core-5fb5dbf697-h79wl 1/1 Running 0 42h
Got it. Now it’s crystal clear:
Your Postgres pod is gone.
The stg-postgresql
service still exists, but it points to nothing—hence your “ghost” connection.
Postgres might have lived in a now-removed namespace.
kubectl get ns
kubectl get svc --all-namespaces | grep stg-postgresql
If it still shows up in postgresql
, but no pods/deployments/PVCs exist in that namespace—then the namespace was partially torn down.
kubectl get svc stg-postgresql -n postgresql -o yaml
Look for:
selector:
app: postgresql
Then:
kubectl get pods -n postgresql -l app=postgresql
You’ll get nothing, confirming: selector is dangling.
If you used Helm:
helm list -n postgresql
helm status -n postgresql
Then redeploy:
helm upgrade --install bitnami/postgresql -n postgresql
Or if it was deployed manually, check Git or infra-as-code repo for YAML and reapply it.
Check:
kubectl get pvc -n postgresql
If the PVC still exists, the data’s safe. Recreate the Postgres pod and mount that PVC back in under /bitnami/postgresql
or whatever path your image expects.
Want to inspect PVC content or rehydrate the deployment? Can guide you step-by-step.
i’m pretty sure the postgres is running and data is there as i can see it on the staging website
Got it, if the data is still live on the staging website, then the Postgres service is running, but the issue likely lies with the connection/port-forward setup.
Here’s the refined plan:
postgresql
namespace when you check with kubectl get pods
—this suggests your Postgres pod might be running under a different namespace or using a non-standard naming convention.Run this to list all pods across all namespaces and search for something that looks like a Postgres pod:
kubectl get pods --all-namespaces | grep postgres
Look for the correct pod name here. It’s likely in a different namespace, or the pod name is different.
Once you identify the correct pod, confirm it’s associated with the service by checking the labels:
kubectl get pod -o yaml -n
Look for the labels
section—verify that it matches the selector in the stg-postgresql
service.
If they match, then stg-postgresql
should be able to forward traffic to it, and the issue might just be with the port-forwarding setup.
Once you confirm the correct pod and namespace, port-forward directly to that pod:
kubectl port-forward pod/ -n 5432:5432
Then, connect via psql
:
psql -h localhost -U postgres -d your_db_name
If everything’s working, you’ll be able to see the data!
kubectl get endpoints stg-postgresql -n
kubectl logs -n
Let me know what you find! I’ll help you figure out if the issue is with the service, the port-forward, or the connection string.
kubectl get pods –all-namespaces | grep postgres yields postgresql stg-postgresql-0 1/1 Running 0 36h
Great, so stg-postgresql-0 is your Postgres pod, and it’s running in the postgresql
namespace. This explains why the service (stg-postgresql
) was still active, but you weren’t seeing any pods directly under the postgresql
namespace with kubectl get pods -n postgresql
—the stg-postgresql-0
pod is a stateful pod, and it likely has a StatefulSet backing it.
Since you’ve now identified the exact pod (stg-postgresql-0
), you can directly port-forward to it.
stg-postgresql-0
):kubectl port-forward pod/stg-postgresql-0 -n postgresql 5432:5432
psql -h localhost -U postgres -d your_db_name
You should be able to access the Postgres instance and see your data now.
If you want to double-check that the stg-postgresql
service is correctly pointing to the stg-postgresql-0
pod:
kubectl get svc stg-postgresql -n postgresql -o yaml
Ensure the service is targeting the correct pod with the appropriate selectors. If everything looks good, but you’re still having issues with Metabase, it might be worth checking the Metabase connection string as well (port-forwarding directly should work, but it might be timing out or misconfigured in the Metabase settings).
Let me know how it goes!
great i can now see the data in metabase, but psql queries still give nothing?
Nice! It sounds like the connection through Metabase is working, which is a good sign that the database is up and running with the data. However, if psql queries still yield nothing, it’s likely an issue with the way you’re connecting via psql
or the permissions/configuration of your psql
session.
Double-check the connection string you’re using with psql
. For example:
psql -h localhost -U postgres -d your_db_name
You can also explicitly set the password if needed:
psql -h localhost -U postgres -d your_db_name -W
Enter the password when prompted.
If you’re connected but see no data, verify you’re using the correct database and schema.
First, list all databases:
\l
Then connect to the correct database:
\c your_db_name
Next, list all tables within the current schema:
\dt
Check which schema you’re currently using:
SHOW search_path;
If needed, set the schema manually:
SET search_path TO schema_name;
If psql
is connected to the correct database but still sees no data, it could be a permissions issue. Check the current user’s permissions:
\du
Ensure the postgres
user (or the user you’re connecting as) has sufficient permissions to access the tables.
Verify that the tables have data. For example:
SELECT COUNT(*) FROM your_table;
If COUNT
returns zero, the tables are empty, and the issue lies elsewhere.
If everything seems correct but issues persist, inspect the Postgres logs for any signs of anomalies:
kubectl logs stg-postgresql-0 -n postgresql
Look for any errors or warnings that might indicate connectivity or data loading issues.
Let me know what you find from these steps! I’m sure we’re close to getting everything working.
pasting complete psql history here
postgres=# SELECT COUNT(*) FROM MEMBERS postgres-# SHOW search_path postgres-# \du List of roles Role name | Attributes | Member of ———–+————————————————————+———– postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
postgres-#
Thanks for pasting that! Based on your history, here’s what stands out:
Let’s dig deeper.
Run this to check if the table truly has data:
SELECT * FROM MEMBERS LIMIT 10;
This will return the first 10 rows. If you get no rows, the table is empty.
You need to ensure you’re in the right schema. Run:
SHOW search_path;
This will show the schema you’re currently in. If it’s empty or not the correct one, set it explicitly:
SET search_path TO public;
After that, run:
SELECT * FROM MEMBERS LIMIT 10;
This will verify whether the data exists in the public
schema or another one.
List all schemas:
\dn
Then, list all tables in all schemas:
\dt *.*
This will ensure you’re seeing everything, even if the table was created in a non-default schema.
If MEMBERS
is empty, check other tables for data:
SELECT COUNT(*) FROM another_table_name;
This will confirm if the issue is specific to one table or applies to others as well.
Once you’ve tried these, let me know what results you get, and we’ll take it from there.
none of these work and i can see table isn’t empty in metabase
Thanks for confirming. Since you can see data in Metabase but psql still shows no results, the issue likely lies in one of these areas:
It’s possible that Metabase is using a different schema than psql
, which is why you’re seeing the data in Metabase but not in psql
.
Run:
SHOW search_path;
This will show the schemas that are currently in use. If the correct schema (where MEMBERS
resides) isn’t in the search path, you’ll need to set it.
To set the schema to public
(or whatever the correct one is):
SET search_path TO public;
Then, try:
SELECT * FROM MEMBERS LIMIT 10;
PostgreSQL is case-sensitive by default. If your table name or column names have uppercase letters (e.g., MEMBERS
), you’ll need to quote them in SQL queries.
Try this in psql
:
SELECT * FROM "MEMBERS" LIMIT 10;
This will handle the case sensitivity issue if the table was created with uppercase letters in its name.
It could be a version mismatch issue where psql is not fully compatible with your Postgres version or there’s some misconfiguration. To check the version of psql
:
psql --version
Then verify the Postgres version running in your pod:
kubectl exec -it stg-postgresql-0 -n postgresql -- psql -U postgres -c "SELECT version();"
Check if there’s any notable discrepancy in version compatibility.
Make sure you’re in the correct database. If you’re connected to a different database than expected, it could cause this issue.
Run:
SELECT current_database();
This will tell you which database you’re connected to. If you’re not in the correct one, switch databases:
\c your_db_name
Check if Metabase is using a different user or connection string. If Metabase is connected with a different user or has additional configuration that gives it access to certain data, you might not have the same privileges in psql
.
Run this to check the user in psql
:
SELECT current_user;
Then, compare it with the user Metabase is using for the connection. If they differ, the issue could be related to user privileges.
psql
.psql
with the one in Metabase.Let me know if any of these steps reveal new information!
it does warn on start WARNING: psql major version 14, server major version 15. Some psql features might not work.
Ah, version mismatch—that could be the root cause. PostgreSQL major version 14 (psql
) doesn’t necessarily work perfectly with a major version 15 server.
Some features, behavior, or optimizations might differ between major versions, and that could explain why you’re seeing data in Metabase (which might be using a more compatible version of psql
) but not in your current psql session.
psql
that matches your Postgres server (version 15). Let’s verify the server version again from inside the pod:kubectl exec -it stg-postgresql-0 -n postgresql -- psql -U postgres -c "SELECT version();"
This confirms that the server is indeed running version 15, which matches the warning.
psql
client to PostgreSQL 15 on your local machine.brew upgrade postgresql
sudo apt-get install postgresql-client-15
After upgrading, reconnect using the new version:
psql -h localhost -U postgres -d your_db_name
Or you can explicitly reference the new version if you have multiple versions installed:
/usr/pgsql-15/bin/psql -h localhost -U postgres -d your_db_name
psql
is not an option or you’d like to test quickly, you can also directly run psql
from within the pod to avoid the local client mismatch:kubectl exec -it stg-postgresql-0 -n postgresql -- psql -U postgres -d your_db_name
This bypasses the local psql
client and ensures compatibility with the Postgres server version running in the pod.
psql
inside the pod directly works.Either way, we should be able to get the data visible in psql
again.
even with the latest version my queries yield nothing
Given that you’re still seeing nothing in psql
even after addressing the version mismatch, here are some additional things to investigate.
Let’s first ensure you’re connected to the correct database and using the right schema.
SELECT current_database();
If you’re not connected to the correct one, run:
\c your_db_name
SHOW search_path;
If it’s not pointing to the correct schema, set it explicitly:
SET search_path TO public;
Then, list the tables:
\dt
Ensure the table you’re trying to query (MEMBERS
) is listed here. If not, check if there’s any other schema by running:
\dn
PostgreSQL treats unquoted table and column names as lowercase. If your MEMBERS
table was created with mixed or uppercase letters, you’ll need to quote the name.
Try querying with quotes around the table name:
SELECT * FROM "MEMBERS" LIMIT 10;
It’s possible that data is being hidden due to Row-Level Security (RLS) or similar configurations.
SELECT * FROM information_schema.table_privileges WHERE table_name = 'MEMBERS';
If Row-Level Security is enabled, check the policies applied to the table:
SELECT * FROM pg_policies WHERE tablename = 'MEMBERS';
If RLS is configured, it might be filtering out data based on the user or session.
Since Metabase is able to see the data, let’s investigate how it’s connecting. It might be using a different user, schema, or filtering mechanism that allows it to view the data when psql
cannot.
psql
has the same permissions and access.
Run this to check your psql
user:SELECT current_user;
Compare that with the user in Metabase’s connection settings.
Check Postgres logs for any errors or warning messages that might provide clues. You can do this by viewing the logs from inside the pod:
kubectl logs stg-postgresql-0 -n postgresql
Look for any unusual entries that might indicate connectivity or permission issues.
At this point, here are the most likely causes:
psql
.Try these steps and let me know what you find! If it’s still not working, we’ll dive deeper into the logs or configuration.
nevermind, i was not ending the queries with ;
Ah, classic! 😄 That’ll do it every time. Not ending a query with a semicolon can cause it to silently wait for more input, so it might seem like it’s not returning anything.
Now that it’s working, is there anything else you need help with, or are you good to go?