W
Wasp-lang6mo ago
Arnab

deployment issues

Hi! I’ve deployed my project on fly.io but the issue is beyond the landing page auth isn’t working. I followed the doc instructions. Perhaps the Prisma DB didn’t deploy? Is there an easy way to see the log and debug? My deployment: https://supastage-client.fly.dev Thanks for the help.
AI Enhanced Interior Design
Interior Designers using AI to create stunning virtual staging.
44 Replies
kapa.ai
kapa.ai6mo ago
Hi @Arnab. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Sure, I can guide you on how to debug this issue. Firstly, you can check the network tab in your browser's developer tools to see if requests to the server are taking a long time or failing. Secondly, you can check the logs on your Fly.io server. To do this, you can use the flyctl logs command. This will show you what is being printed on the server, whether it's getting requests from the client, and if it's reporting any errors. If you suspect that the issue might be with the Prisma DB, you can connect to your Fly production database and interact with it using Prisma Studio. To do this, you can open up a tunnel with fly proxy 5432 -a <db-name>. After setting up the tunnel, you can execute wasp db studio to interact with the database. Just remember to remove the DATABASE_URL with the production database URL from .env.server if you put it there, so you don't accidentally do something you didn't want to on the production database later. Here are the relevant sources for your reference: - Discord support thread: My login tab on the frontpage went missing after deployment on fly.io > Answers Part 2 (https://discord.com/channels/686873244791210014/1217941277979574315) - Discord support thread: How to interact with database in prisma studio after deployment? > Answers (https://discord.com/channels/686873244791210014/1220423321422663820) - Docs > Advanced > Deployment > Deploying Manually > Fly.io (server and database) > Deploy to a Fly.io App (https://wasp-lang.dev/docs/advanced/deployment/manually#deploy-to-a-flyio-app) I hope this helps! Let me know if you have any other questions. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Arnab, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
martinsos
martinsos6mo ago
So I just gave it a quick try, and I see that the server is not responding, requests are taking super long time and never happen. Was the app working at any point, or is this from the start since you deployed? Can you check the logs on Fly for the server? What about logs for the database? One common problem is that people forget to provide all the env vars for the server on Fly, so the server doesn't start properly.
Arnab
Arnab6mo ago
Thanks for the help. It's working locally. But it's never worked after deploying. The logs don't have errors. The env vars are likely the issue. I put the info in the .env.server in the project. Is there a step that I'm missing or how do I make sure that the env vars are properly moved over?
martinsos
martinsos6mo ago
Let's figure this out, couple of questions: 1. Could you still copy the logs that you have, so we can see what they look like, for the server on Fly? There might be something there that is not obvious at the first glance. 2. How did you deploy to Fly, did you use these instructions https://wasp-lang.dev/docs/advanced/deployment/cli ? 3. Server vars -> so it will not pick up vars from .env.server, those are only for your local development. You need to set env vars on the Fly server yourself, those are vars you will use for production. I realize now this is not mentioned explicitly in the instrutions above hm, I wonder if we should add that to that piece of docs. Here is a piece about it from the "manual deployment" section of the docs: https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables .
Arnab
Arnab6mo ago
Here's the logs: Yes I followed the instructions on the CLI. I 3. Ahh ok that makes more sense. I understood that wasp deploy command took care of all that. Also do you guys recommend hosting the DB on fly.io or some other service? I'm trying to keep it simple, cheap and quick to deploy
martinsos
martinsos5mo ago
If you want to go for simple and quick, I would say stick to Fly at the moment, due to Wasp's wasp deploy fly functionality. It is also not expensive, although not free unfortunately. We will be looking to provide more options in the future that are this streamlined and hopefully some that are free, but for now this sounds like the easiest one. And yeah, also host DB there then. As for your issue -> did setting up the env vars help? As for logs from the server -> ok, so these logs are not that useful, true, because the useful ones are probably quite old. What you can try is redeploy your app on Fly (using wasp deploy fly deploy), and then, right after deployment was successful, go checkout the logs of the server again. You should see more useful logs, something like "server is starting", and potentially any interesting errors also.
Arnab
Arnab5mo ago
Trying it now. Solid help! Sorry I'm a bit of a noob. I'm still getting errors after updating the envs:" 2024-05-22T14:36:31Z proxy[e286de4f920486] mia [error][PM05] failed to connect to machine: gave up after 15 attempts (in 16.413149496s) 2024-05-22T14:36:31Z proxy[e286de4f920486] mia [error][PM05] failed to connect to machine: gave up after 15 attempts (in 16.458412933s) " Also what configuration do I need for the host machines, and for which (server, db, client)? Right now I'm on the development shared.
Arnab
Arnab5mo ago
Ok so I redeployed the project. I also set the secrets as you suggested. But login isn't working! arrghhh Here's the logs from server, client, and db right after deploying and trying to login.
Arnab
Arnab5mo ago
I'd appreciate the help From the logs it seems like server keeps restarting.... which is weird. Is it because I'm on a 1 shared? Also another noob question. All the .env.server keys etc are they all automatically added or do I need to add them somehow?
martinsos
martinsos5mo ago
Hey no worries, the whole deployment thing is realtively complicated, even for me with quite some experience! OK, so indeed your Fly machine for the supastage-server is complaining a lot about restarting machine and stuff, I am nto sure what are all those errors about (that is on the Fly side). You could check with their support for help on that. Maybe take a look at metrics (cpu, memory), is that looking all good. As for the logs, I found the error in the supastage-server logs:
2024-05-23T02:38:40.486 app[0806d4ef615058] ewr [info] API key does not start with "SG.".

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] /app/src/server/actions.ts:38

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] throw new HttpError(500, 'Email environment variables are not set correctly');

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] ^

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] HttpError: Email environment variables are not set correctly

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] at <anonymous> (/app/src/server/actions.ts:38:9)

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] statusCode: 500

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] }
2024-05-23T02:38:40.486 app[0806d4ef615058] ewr [info] API key does not start with "SG.".

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] /app/src/server/actions.ts:38

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] throw new HttpError(500, 'Email environment variables are not set correctly');

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] ^

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] HttpError: Email environment variables are not set correctly

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] at <anonymous> (/app/src/server/actions.ts:38:9)

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] statusCode: 500

2024-05-23T02:38:40.635 app[0806d4ef615058] ewr [info] }
From this, I am guessing your Sendgrid API key is not set to a proper value, but to a mock value, and that is why server won't start. So .env.server remains on your machine, doesn't goa nywhere. It is only for development. On Fly, you need to set the env vars manually. We set some of them for you if you are using wasp deploy fly deploy, specifically DATABASE_URL, and JWT_SECRET, and PORT, but the rest you need to set on your own. So for example, if you need Sendtring key, you will need to set that manually on Fly, specifically for your supastage-server machine. You can do this like this:
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=https://mycoolapp.com
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=https://mycoolapp.com
and do it multiple times for any secret you need to set. You can also check which secrets you already have set, by running wasp deploy fly cmd --context server secrets list Which docs were you following for all this so far? I guess https://wasp-lang.dev/docs/advanced/deployment/cli ? I am looking at them again and they are really lacking this info on setting server env vars, that sucks, I will make sure we improve that! Ok, I created an issue for it here, we will be improving these docs soon! https://github.com/wasp-lang/wasp/issues/2053
Arnab
Arnab5mo ago
Amazing help! I really appreciate this. I'm trying it now. I was using the Opensaas docs, which have even less lol.
MEE6
MEE65mo ago
Wohooo @Arnab, you just became a Waspeteer level 3!
martinsos
martinsos5mo ago
Hm you are right, docs in open-saas give just enough info to make you feel like you know all that is needed to deploy, but not enough to actually deploy successfully! I also opened an issue for that, we will make sure to fix this! https://github.com/wasp-lang/open-saas/issues/139 Thanks a lot for the effort and patience here, this will help others 🙂
Arnab
Arnab5mo ago
Thank you! OK I pushed all the envs to the server and I'm still getting server errors. Also, when I try to do the google auth (https://supastage-server.fly.dev/auth/google/login) I get the page isn't working
Arnab
Arnab5mo ago
More logs "2024-05-23T17:20:03.893 proxy[148e057c001189] ewr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on) 2024-05-23T17:20:12.473 proxy[0806d4ef615058] ewr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on) 2024-05-23T17:20:14.479 proxy[148e057c001189] ewr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on) 2024-05-23T17:20:22.489 proxy[0806d4ef615058] ewr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on) 2024-05-23T17:20:24.495 proxy[148e057c001189] ewr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on) 2024-05-23T17:20:31.503 proxy[148e057c001189] lga [error] [PR04] could not find a good candidate within 90 attempts at load balancing" If you happen to be online now. I could jump on a google meet, instead of the back and forth. There's got to be something stupid I'm messing up lol
Vinny (@Wasp)
Vinny (@Wasp)5mo ago
did you add the URL of your Server to your Authorized Redirct URI's section in Google Cloud? https://wasp-lang.dev/docs/auth/social-auth/google#3-creating-a-google-oauth-app
Google | Wasp
Wasp supports Google Authentication out of the box.
Vinny (@Wasp)
Vinny (@Wasp)5mo ago
Did you aslo set the JWT_SECRET environment variable on the server?
Arnab
Arnab5mo ago
Yes I set JWT. Yes on google auth also
No description
Arnab
Arnab5mo ago
Hey guys I appreciate your help here. Any chance we could jump on a quick call to fix the issue? It may be faster, and I'm trying to deploy asap.
Arnab
Arnab5mo ago
Yes
No description
Arnab
Arnab5mo ago
@martinsos any chance you can help with the deployment issues?
Vinny (@Wasp)
Vinny (@Wasp)5mo ago
@Arnab which version of wasp are you on? if you're on 0.12 or lower it should be .../auth/login/google , but if you're on 0.13 it should be .../auth/google/callback also could you share your server logs when you login with google. Here's what a successful login looks like in v0.13
[ Server ] GET /auth/google/login 302 6.702 ms - -
[ Server ] GET /auth/google/callback?state=0eoQWY9_b2gNsp9PXPwdGVCMII08kq0UE6VXYx2ZDtI&code=4/0AdLIrYdFrzB-ayNybVeeAwgkFyLOft7-1pVFMQjW5Zk6XhTaSKbiTsNRlPSG33LfRItT2g&scope=email%20profile%20openid%20https://www.googleapis.com/auth/userinfo.profile%20https://www.googleapis.com/auth/userinfo.email&authuser=0&prompt=consent 302 565.356 ms - -
[ Server ] GET /auth/me 401 5.730 ms - 43
[ Server ] POST /auth/exchange-code 200 59.033 ms - 56
[ Server ] GET /auth/google/login 302 6.702 ms - -
[ Server ] GET /auth/google/callback?state=0eoQWY9_b2gNsp9PXPwdGVCMII08kq0UE6VXYx2ZDtI&code=4/0AdLIrYdFrzB-ayNybVeeAwgkFyLOft7-1pVFMQjW5Zk6XhTaSKbiTsNRlPSG33LfRItT2g&scope=email%20profile%20openid%20https://www.googleapis.com/auth/userinfo.profile%20https://www.googleapis.com/auth/userinfo.email&authuser=0&prompt=consent 302 565.356 ms - -
[ Server ] GET /auth/me 401 5.730 ms - 43
[ Server ] POST /auth/exchange-code 200 59.033 ms - 56
Arnab
Arnab5mo ago
0.13.2 I've already shared the logs above. Nothing about google auth is showing up. I keep getting the same errors "2024-06-04T15:38:39.219 proxy[0806d4ef615058] ewr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on) 2024-06-04T15:38:47.140 proxy[148e057c001189] ewr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on) 2024-06-04T15:38:47.156 proxy[148e057c001189] dfw [error] [PR04] could not find a good candidate within 90 attempts at load balancing 2024-06-04T15:38:50.181 proxy[0806d4ef615058] ewr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on) 2024-06-04T15:38:57.393 proxy[148e057c001189] ewr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on) 2024-06-04T15:39:01.020 proxy[0806d4ef615058] ewr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on) 2024-06-04T15:39:04.309 proxy[148e057c001189] lga [error] [PR04] could not find a good candidate within 90 attempts at load balancing Am I making a mistake with the type of instance? I'm using "shared-cpu-1x@1024MB" @martinsos I see that you may be online to help? I've been trying to fix this issue for a few weeks. I'd really apprecaite the help.
Arnab
Arnab5mo ago
No description
Arnab
Arnab5mo ago
Also in the oAuth do I keep it on testing or prod? If it's on prod doesn't it need a custom domain?
miho
miho5mo ago
Let's jump on a call tomorrow and try to figure it out. I'm free 9 am to 2 pm CEST
Arnab
Arnab5mo ago
thank you! I'm in EDT. I think 2pm CEST is 8am EST. I can do 1:30pm CEST if needed.
martinsos
martinsos5mo ago
Awesome! THanks @miho . Sorry for not responding sooner @Arnab , I was swamped, but also, @miho will be able to offer much better help, he knows this stuff quite better than me!
miho
miho5mo ago
Let's try 1:30 if possible 👍 send me a DM and I'll send you a meet link
Arnab
Arnab5mo ago
Awesome! Talk soon Thanks for the help @miho still free in 10 min?
miho
miho5mo ago
Yep, let's do it
rdm
rdm5mo ago
Hi @Arnab, Any updates? I hope you figured it out. I'm having the same issue 🙂
Arnab
Arnab5mo ago
Yes, @miho helped fix the issue. The issue I ran into was with one of the secrets. The EMAIL_PASSWORD secret I had set via terminal and forgot the "". I'd go to fly.io and set it directly on their dashboard. Also you can add a "console.log (emailUsername, emailPassword)" after line 35 for logs in actions.ts.
MEE6
MEE65mo ago
Wohooo @Arnab, you just became a Waspeteer level 4!
Arnab
Arnab5mo ago
Also make sure your port secret is 8080
rdm
rdm5mo ago
Oh, great to hear, congrats! Thank you for your feedback, I'll try it, and also good luck with your product launch!
miho
miho5mo ago
We also updated the PORT env var on Fly to be 8080 😊
rdm
rdm5mo ago
Thank you @miho , I'll give it a try, and provide feedback 😃 It worked, thank you guys (@Arnab @miho @martinsos ) ❤️
miho
miho5mo ago
Nice! What was your exact issue?
martinsos
martinsos5mo ago
I created a special issue just for this, because our system for reporting missing env vars in production is not great and having a better thign in place could help quite a bit: https://github.com/wasp-lang/wasp/issues/2086 . I still didn't quite get what the issue was though: @Arnab , you had EMAIL_PASSWORD secret set in .env.server, for local development, but you forgot to set it on Fly.io, is that it? What do you mean with adding a console.log? Port -> @miho don't we set that for them when deploying to Fly? You somehow changed its value by accident @Arnab so that caused additional issues? @rdm what was your problem?
Arnab
Arnab5mo ago
Hey @martinsos I think the issue is that I'm a noob coder lol. The issue that miho helped with is that I pushed all the envs via terminal. But when you are sending a password with spaces (Google email password) it screws it up if quotes aren't included. So I set it directly on the fly dashboard. It was a very simple issue, that I think a more experience coder would know. Maybe as a suggestion make it easier to set secrets/ pass along envs?
No description
Arnab
Arnab5mo ago
I also suggested to miho to record a video of deploying on youtube. I think videos on youtube would be super helpful in general. I'm happy to do a quick video and share. Lmk
martinsos
martinsos5mo ago
@Arnab I could imagine myself easily making the same mistake! At Wasp we really don't want people to have to bother with such details, so I would certainly like us to help with this somehow. Those are good ideas! I would formalize it like this: 1. Allow people to define production env variables via .env.production if they wish. Although this needs to be done properly on our side, so it is a bit more work for us, especially desiging the experinec here to be right. 2. Improve the docs, by also warning people about quotes and giving more clear examples on how to do it. 3. Finally add video as you said! Videos are on one hand very valuable, but on the other hand tricky to maintain because if sometihng cahnges, editing / redoing video is much more expensive then editing text, so that is why we don't have a lot of them. Well, initial production is also more time consuming. But having one video of deployment process, that might be reasonable. If you would like to do a quick video that would be cool, absolutely! Ok, here is the issue where we are tracking this issue, I will make sure we prioritize it in the following sprints!
Vinny (@Wasp)
Vinny (@Wasp)5mo ago
We could also add instructions to our deployment docs for adding the env vars on Fly.io's dashboard -- this is how I also did it for Open SaaS 🙂
Want results from more Discord servers?
Add your server