Port error when deploying with Fly

When I try to deploy using fly.io. I use the exact commands and ahve not changed anything about my code. I get this error: WARNING The app is not listening on the expected address and will not be reachable by fly-proxy. You can fix this by configuring your app to listen on the following addresses: - 0.0.0.0:3000 Found these processes inside the machine with open listening sockets: PROCESS | ADDRESSES
-----------------*--------------------------------------- /.fly/hallpass | [fdaa🅰️d462:a7b:2eb:84ef:c82f:2]:22
Creating a second machine to increase service availability ✔ Machine 6830de1f79d028 [app] was created ✔ Machine 6830de1f79d028 [app] update finished: success Finished launching new machines NOTE: The machines for [app] have services with 'auto_stop_machines = "stop"' that will be stopped when idling Checking DNS configuration for myapp-server.fly.dev Visit your newly deployed app at https://myapp-server.fly.dev/ The server does not work on prod beucase its not listing on the right port despite the toml file containing this [http_service] internal_port = 3000 force_https = true auto_stop_machines = 'stop' auto_start_machines = true min_machines_running = 1 processes = ['app']
13 Replies
kapa.ai
kapa.ai2w ago
Hi @Outseek. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in your question and the knowledge sources available, it appears you're encountering a port-related issue when deploying your Wasp application to Fly.io. Let's address this problem step by step. 1. Port Configuration: The error message suggests that your app is not listening on the expected address (0.0.0.0:3000). This is a common issue when deploying to Fly.io with Wasp applications. 2. Environment Variable: One crucial step that might be missing is setting the PORT environment variable. According to the Wasp deployment docs (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app), you should set this variable:
flyctl secrets set PORT=8080
flyctl secrets set PORT=8080
Note that the docs suggest using port 8080, not 3000. This is important because Fly.io expects your application to listen on the port specified by the PORT environment variable. 3. Server Configuration: In your Wasp application, make sure your server is configured to listen on the port specified by the PORT environment variable, not a hardcoded value like 3000. 4. fly.toml Configuration: Your fly.toml file seems to be set up correctly with internal_port = 3000. However, this should match the PORT environment variable you set. Consider updating it to:
[http_service]
internal_port = 8080
# ... other configurations
[http_service]
internal_port = 8080
# ... other configurations
5. Dockerfile: If you're using a custom Dockerfile, ensure it's configured to use the PORT environment variable when starting your server. 6. Redeployment: After making these changes, try redeploying your application:
flyctl deploy --remote-only
flyctl deploy --remote-only
If you're still encountering issues after these steps, you might want to check the server logs for more detailed error messages:
flyctl logs
flyctl logs
Remember, Wasp generates the deployment code in the .wasp/build/ directory. You can inspect this code to ensure everything is set up correctly before deployment, as mentioned in the Discord support thread (https://discord.com/channels/686873244791210014/1223671727943319584). If these steps don't resolve your issue, you may need to provide more information about your specific Wasp application setup and deployment process for further assistance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Outseek, 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?
Outseek
OutseekOP2w ago
I just followed all of that but still getting this error WARNING The app is not listening on the expected address and will not be reachable by fly-proxy. You can fix this by configuring your app to listen on the following addresses: - 0.0.0.0:8080 Found these processes inside the machine with open listening sockets: PROCESS | ADDRESSES
-----------------*--------------------------------------- /.fly/hallpass | [fdaa🅰️d462:a7b:2eb:84ef:c82f:2]:22
[1/2] Running smoke checks on machine 32871562cd9708
NEROX
NEROX2w ago
@Outseek Could you check if you have log errors in the fly app (server)? ps: did you set all env vars in the server/client?
martinsos
martinsos2w ago
@Outseek any way to provide more info? Have you ever before successfuly deployed Wasp app to Fly? What version of Wasp is it? Did you modify that toml file in any way? Are there any errors coming from server, on the fly, under logs?
Outseek
OutseekOP2w ago
Yes there are errors in the fly logs. I did not modify the toml in any way. I even created a new fly account and tried to get it to work. here are the logs. 2024-11-06T14:12:12.744 runner[0801ed9a641e98] mia [info] Machine started in 13.39s 2024-11-06T14:12:13.380 app[56830de2f22798] mia [info] INFO Starting init (commit: 74e923d)... 2024-11-06T14:12:14.022 proxy[0801ed9a641e98] mia [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:3000? 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) TOML file fly.toml app configuration file generated for basebuddyapp-server on 2024-11-05T21:32:20-05:00 See https://fly.io/docs/reference/configuration/ for information about how to use this file. # app = 'basebuddyapp-server' primary_region = 'mia' [build] [http_service] internal_port = 3000 force_https = true auto_stop_machines = 'stop' auto_start_machines = true min_machines_running = 1 processes = ['app'] [[vm]] memory = '1gb' cpu_kind = 'shared' cpus = 1 and yes I have tried to set PORT=3000 but that has never worked. Do all of them NEED to be set. Seems like an unrelated issue becuase the sever is not even connected Also I have never deployed it successfully. Only the client and database work not the server
NEROX
NEROX2w ago
Well, Idk, Its a possibility
NEROX
NEROX2w ago
Have you done (?):
#### Server Secrets If your app requires any other server-side environment variables (like social auth secrets), you can set them: 1. initially in the launch command with the --server-secret option,
or 2. after the app has already been deployed by using the secrets set command:
<span class="token-line" style="color: rgb(57, 58, 52);"><span class="token plain">wasp deploy fly cmd secrets set GOOGLE_CLIENT_ID=&lt;...&gt; GOOGLE_CLIENT_SECRET=&lt;...&gt; --context=server</span></span>
<span class="token-line" style="color: rgb(57, 58, 52);"><span class="token plain">wasp deploy fly cmd secrets set GOOGLE_CLIENT_ID=&lt;...&gt; GOOGLE_CLIENT_SECRET=&lt;...&gt; --context=server</span></span>
https://wasp-lang.dev/docs/advanced/deployment/cli
Deploying with the Wasp CLI | Wasp
Wasp CLI can deploy your full-stack application with only a single command.
NEROX
NEROX2w ago
If it compiles well in local (it happened to me), when deploying it gave me the same problem as you. I realized that the port error was because my machine was turned off BECAUSE the Server had crashed and rebooted 10 times and .... why? Because I left some server variable like Analytics or other, and gave server compilation error, so it crashes and restarted.
Outseek
OutseekOP2w ago
Okay and the variables you are reffering to those in the ENV file? @NEROX
NEROX
NEROX2w ago
Yes
martinsos
martinsos2w ago
@Outseek , it is hard for me to say more from this -> is there any chance tehre are more logs coming from the server logs? I believe there should be more. There is a fair possibility that your server is not running and that is why there is nobody listening on port 3000. Reason for this is often not setting all the env vars, so server is crashing. It is not super easy for me to asnwer what you need, but the answer is normally in the logs. You can look into your .env.server file and see if thre is anything set there but nt in production, that should give you a good idea. Other than that, what can help is if we can replicate the issue and test it ourselves. For exapmle, you cuold try with simpler wasp app, sometihng basic, and if that also doesn't work, share the code with us and we will giv it a try.
Outseek
OutseekOP2w ago
Okay Ill try to set all the env vars and tehn see if that fixes it!
MEE6
MEE62w ago
Wohooo @Outseek, you just became a Waspeteer level 1!
Want results from more Discord servers?
Add your server