Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl http://localhost:3000/todos returns {"hint":null,"details":null,"code":"42P01","message":"relation \"api.todos\" does not exist"} #1009

Closed
amadeuspagel opened this issue Nov 7, 2017 · 16 comments

Comments

@amadeuspagel
Copy link

I followed the tutorial and

curl http://localhost:3000/todos

returns:

{"hint":null,"details":null,"code":"42P01","message":"relation \"api.todos\" does not exist"}

@ruslantalpa
Copy link
Contributor

ruslantalpa commented Nov 7, 2017 via email

@amadeuspagel
Copy link
Author

I already tried that and that works, I get:

id | done | task | due
----+------+-------------------+-----
1 | f | finish tutorial 0 |
2 | f | pat self on back |
(2 rows)

@ruslantalpa
Copy link
Contributor

although it's not likely, try restarting postgrest.

after that please post a copy/paste of the entire console session for the following commands

  • cat postgrest.conf
  • psql
    • select * from api.todos;

@amadeuspagel
Copy link
Author

Restarting didn't help.

I'm using c9, so I can't access postgrest.conf

But here is:

ubuntu=# select * from api.todos;
 id | done |       task        | due 
----+------+-------------------+-----
  1 | f    | finish tutorial 0 | 
  2 | f    | pat self on back  | 
(2 rows)

@ruslantalpa
Copy link
Contributor

this does not help, the point was to compare the connection string you put in postgrest.conf with the way to connect directly to the db and make sure you are not mixing things. the result of th query is irelevant

@amadeuspagel
Copy link
Author

I read "postgres.conf" thought it was something related to postgresql not postgrest.

I have a tutorial.conf file:

db-uri = "postgres://postgres:mysecretpassword@localhost/postgres"
db-schema = "api"
db-anon-role = "web_anon"

@ruslantalpa
Copy link
Contributor

ok, so here is what i don't get.
you say you are using c9 (which i am not familiar with) then you paste your conf file which references the localhost.
If you are running postgrest in c9 that means localhost is that remote computer, not your computer, while you are probably using using psql with the same connection string and that gets you connected to the postgre instance on your actual computer, not the db where postgrest running in c9 is connecting.
Tutorial was written with the idea that you are doing everything on your actual computer. If you start mixing different remote environments then you are on your own :) to figure out what is going wrong.

(to reiterate, IMO this is what's happening, postgrest is connecting to the database that is on the same host where it is running, i.e. c9, while you executed the sql from the tutorial using psql on your computer and not the db where postgrest is connecting)

@ruslantalpa
Copy link
Contributor

did you figure it out? was ti the c9 thing?

@begriffs
Copy link
Member

begriffs commented Feb 4, 2018

@amadeuspagel did you make any progress with this?

@makeitrein
Copy link

makeitrein commented Mar 10, 2018

Ran into the same issue - resolved by turning off PostgresApp... Postgrest was connecting to my local Postgres rather than Docker - cheers!

@steve-chavez
Copy link
Member

Closing due to lack of activiy, reopen if problem persists.

@CygaLV
Copy link

CygaLV commented Feb 8, 2019

Hi,

I've the same issue here.
I tought it was because my tables were not in lower case. So I tried a dummy test and create a db and 1 table in lower case : same issue.

Running x64 windows version. Pg is in version 10.0
HTTP command : GET http://localhost:3000/flattable
db name : pgwebtest
mytest.conf:
db-uri = "postgres://postgres:postgres@localhost:5432/"
db-schema = "pgwebtest"
db-anon-role = "web_anon"

webservice answer:
HTTP/1.1 404 Not Found
Transfer-Encoding: chunked
Date: Fri, 08 Feb 2019 03:21:03 GMT
Server: postgrest/5.2.0 (1e732ac)
Content-Type: application/json; charset=utf-8

{"hint":null,"details":null,"code":"42P01","message":"relation "pgwebtest.flattable" does not exist"}

PostgREST connects successfully. My table is in the public schema of my db.

Any idea ?

@steve-chavez
Copy link
Member

@CygaLV Should be db-uri = "postgres://postgres:postgres@localhost:5432/pgwebtest" and db-schema="public"

@orlowang
Copy link

hi, I got same issue, here is some info

  1. db logs:
2019-02-16 17:21:59.918 UTC [1] LOG:  database system is ready to accept connections
2019-02-16 17:22:01.717 UTC [29] ERROR:  relation "fling.user_base" does not exist at character 61
2019-02-16 17:22:01.717 UTC [29] STATEMENT:  
            WITH pg_source AS (SELECT "fling"."user_base".* FROM "fling"."user_base"    ) SELECT null AS total_result_set, pg_catalog.count(_postgrest_t) AS page_total, array[]::text[] AS header, coalesce(json_agg(_postgrest_t), '[]')::character varying AS body
            FROM ( SELECT * FROM pg_source) _postgrest_t 
  1. I search with same schema in db is ok
postgres=# SELECT "fling"."user_base".* FROM "fling"."user_base";
 avatar | create_time | gender | id | location | marital_status | name | password | update_time 
--------+-------------+--------+----+----------+----------------+------+----------+-------------
(0 rows)
  1. some of my docker-compose.yml
  api:
    image: postgrest/postgrest
    environment:
      PGRST_DB_URI: postgres://postgres:password@db:5432/fling
      PGRST_DB_SCHEMA: fling
      PGRST_DB_ANON_ROLE: web_anon
  db:
    image: postgres
    environment:
      POSTGRES_DB: fling
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password

I just fllow the tutorial, no more change for config. help me pls!

@steve-chavez
Copy link
Member

The postgrest docker container is probably connecting to your local db(on 5432 port). Specify the ports of your db in docker-compose(on port 5433 maybe) and connect postgrest to that instance.

@Pigeo
Copy link

Pigeo commented Apr 6, 2020

I solved the problem.
In my case, it was because I had created the schema and the table in another database than the default one (postgres). If you do so, don't forget to change the name of the database at the end of the URL : db-uri = "postgres://authenticator:mysecretpassword@localhost:5433/YOUR-DATABASE-NAME"

amandamcg added a commit to amandamcg/postgrest-docs that referenced this issue Apr 19, 2021
This note helps people who are hitting this error `{"hint":null,"details":null,"code":"42P01","message":"relation \"api.todos\" does not exist"}`

PostgREST/postgrest#1009
wolfgangwalther pushed a commit to amandamcg/postgrest-docs that referenced this issue Apr 19, 2021
This note helps people who are hitting this error `{"hint":null,"details":null,"code":"42P01","message":"relation \"api.todos\" does not exist"}`

PostgREST/postgrest#1009
wolfgangwalther pushed a commit to PostgREST/postgrest-docs that referenced this issue Apr 19, 2021
This note helps people who are hitting this error `{"hint":null,"details":null,"code":"42P01","message":"relation \"api.todos\" does not exist"}`

PostgREST/postgrest#1009
monacoremo pushed a commit to monacoremo/postgrest that referenced this issue Jul 17, 2021
This note helps people who are hitting this error `{"hint":null,"details":null,"code":"42P01","message":"relation \"api.todos\" does not exist"}`

PostgREST#1009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

8 participants