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

Realworld app returning Network Error #460

Closed
kalle3e opened this issue Feb 11, 2022 · 8 comments
Closed

Realworld app returning Network Error #460

kalle3e opened this issue Feb 11, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@kalle3e
Copy link

kalle3e commented Feb 11, 2022

Describe the bug

Downloaded the code, wasp build and wasp start and on registering user it returns "Network Error"

Error:
From wasp db migrate-dev ---

Environment variables loaded from .env
Prisma schema loaded from ../db/schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "localhost:5432"

Error: P1001: Can't reach database server at localhost:5432

Please make sure your database server is running at localhost:5432.
Error: Migrate dev failed: Migrate (dev) failed with exit code: 1
kitt@x2:~/realworld$

To Reproduce
Steps to reproduce the behavior:

Followed the README.md and run docker:
docker run --rm --publish 5432:5432 -v postgresql-data:/var/lib/postgresql/data --env POSTGRES_PASSWORD=devpass postgres

System message: 2022-02-11 04:21:48.570 UTC [1] LOG: database system is ready to accept connections

.env in the project root
/home/kitt/realworld/.env
.env file
Screenshot from 2022-02-11 16-23-08
contains
SKIP_PREFLIGHT_CHECK=true;
DATABASE_URL="postgresql://postgres:devpass@localhost:5432/postgres";

Expected behavior
A clear and concise description of what you expected to happen.

Expected the system to create the user

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Laptop, Ubuntu 20.04, Chrome V 97.0.4692

Additional context
Add any other context about the problem here.

Error: migrating database
Error: P1001: Can't reach database server at localhost:5432

Please make sure your database server is running at localhost:5432.
Error: Migrate dev failed: Migrate (dev) failed with exit code: 1

@Martinsos
Copy link
Member

Martinsos commented Feb 11, 2022 via email

@kalle3e
Copy link
Author

kalle3e commented Feb 11, 2022

Hi Martin, thanks your your reply.

I run the realworld app on my laptop that has ubuntu 20.04

The db is run by docker run --rm --publish 5432:5432 -v postgresql-data:/var/lib/postgresql/data --env POSTGRES_PASSWORD=devpass postgres

Message from this command:
Screenshot from 2022-02-11 18-53-33

wasp db migrate-dev

Migration done.
Copying migrations folder from Prisma to Wasp project...
Done copying migrations folder.
All done

Screenshot from 2022-02-11 18-35-43

Now getting error:
Screenshot from 2022-02-11 18-56-50

I run realworld app in /home/kitt on ubuntu 20.04, not in a docker container. Also after running postgres container I leave it on, that's why we can see the error about the "2022-02-11 07:47:35.824 UTC [54] LOG: invalid length of startup packet" .

OK. I found outthat when I do localhost:5432 I get the error about the 2022-02-11 08:17:00.819 UTC [44] LOG: invalid length of startup packet.
I'm going to check my localhost in the /etc/hosts now. It's probably something wrong here.

Update: I have checked my hosts and can go to the localhost but still can't go to localhost:5432 and getting the invalid length of startup packet error. I don't understand why docker is returning this error
Screenshot from 2022-02-11 18-56-50
.

@Martinsos
Copy link
Member

Hmmmm, so it is not an issue related to Wasp, instead it seems to do with the Docker image for Postgresql.

I found some possibly related issues here:

I also found others mentioning the issue on different places, but I can't seem to find one clear answer pointing to a well defined problem.

I removed my local postgres docker image, to make sure I pull the latest one, hoping that will replicate the problem you are having, but no luck there - it works fine for me and I don't get any "invalid length of startup packet" messages - not when doing stuff via Wasp.

One way I can get "invalid length of startup packet" messages is if I try opening localhost:5432 in the browser -> which makes sense, because it sends HTTP packages but postgres server is expecting something else, not HTTP requests.

So my question would be: when do you get that error? If when visiting localhost:5432 in browser, then that is probably ok, and not a problem at all. What about when using Wasp -> does Wasp work for you now? After you turn on the database, and after you do wasp db migrate-dev and then wasp start, is everything ok? If you then try to sign in and create new user, does that work?

@kalle3e
Copy link
Author

kalle3e commented Feb 12, 2022

Bravo, thanks very much Martin. I've got it working now thanks! I think I ran the db docker command outsite of the project dir and then I tried to fix problems running the localhost:5432 on the browser, but you said we don't do that. All good! Happy to have a look around with the code and wasp. It helps when you're more confident with working with a docker container to start with.

@kalle3e kalle3e closed this as completed Feb 12, 2022
@Martinsos
Copy link
Member

@kalle3e great, I am glad we figured it out! Good luck with Wasp and feel free to reach out if you have any questions/feedback, either here or on our Discord server!

@kislaySinha1999
Copy link

can u plz explain how u solved this problem in a lil detail?

@kalle3e
Copy link
Author

kalle3e commented Jan 17, 2024 via email

@Martinsos
Copy link
Member

can u plz explain how u solved this problem in a lil detail?

Are you experiencing similar issue? Let me know exactly what you are struggling with and I can try to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants