WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.You

I get that error during deployment. 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 How do i set the port? I have noticed in the opensaas documentatoin that it mentions that porst are automaticaly pulled from the env.server file. https://docs.opensaas.sh/guides/deploying/ Do I just add the port there and redeploy or does this get set somewhere else?
OpenSaaS.sh
Deploying
Open SaaS is a free, open-source, full-stack SaaS starter kit for React + NodeJS.
No description
18 Replies
kapa.ai
kapa.ai3mo ago
Hi @fred-123. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Yes, you can set the port in the .env.server file. According to the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables), the PORT environment variable is used to specify the server's HTTP port number. This is where the server listens for requests. The default value is 3001. To set the port, you can add the following line to your .env.server file:
PORT=3001
PORT=3001
Replace 3001 with the port number you want to use. After setting the port, you can try to redeploy your application. However, if you are deploying to Fly.io, you might need to set the port using the flyctl secrets set command. This is mentioned in the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app) for setting up a Fly.io app:
flyctl secrets set PORT=8080
flyctl secrets set PORT=8080
Replace 8080 with the port number you want to use. This command sets the PORT environment variable for your Fly.io app. Please note that the port number you set should match the internal_port in the fly.toml file. This was mentioned in a Discord support thread (https://discord.com/channels/686873244791210014/1204929776272281641) where a community member changed the internal_port to 4321 in the fly.toml file and exposed it in the Dockerfile. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @fred-123, 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?
fred-123
fred-1233mo ago
@kapa.ai How come the port is not included in the env.server.example? Are there cases where this is not needed?
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- The PORT environment variable is not included in the .env.server.example file because it has a default value of 3001 in Wasp. This means that if you don't specify a PORT in your .env.server file, Wasp will automatically use 3001 as the port number for the server. However, there might be cases where you need to specify a different port number. For example, if you have another application running on port 3001, you would need to set a different port for your Wasp app to avoid a port conflict. Another example is when you are deploying your app and the deployment platform requires you to use a specific port number. In these cases, you would need to add the PORT environment variable to your .env.server file and set it to the desired port number. For example:
PORT=4000
PORT=4000
This will set the server's port number to 4000. Remember to also update the WASP_WEB_CLIENT_URL environment variable in your .env.server file if you change the server's port number. This variable is used to specify the URL of the web client, and it should include the server's port number. For example:
WASP_WEB_CLIENT_URL=<http://localhost:4000>
WASP_WEB_CLIENT_URL=<http://localhost:4000>
This will set the web client's URL to <http://localhost:4000.> You can find more information about environment variables in Wasp in the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @fred-123, 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?
fred-123
fred-1233mo ago
@kapa.ai i am refering to production hosted on fly.io not the localhost version
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- When deploying your Wasp app to a production environment like Fly.io, the PORT environment variable is typically set by the platform itself. In the case of Fly.io, it automatically assigns a port for your application to listen on. However, you can explicitly set the PORT environment variable for your Fly.io app using the flyctl secrets set command, as mentioned in the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app):
flyctl secrets set PORT=8080
flyctl secrets set PORT=8080
Replace 8080 with the port number you want to use. This command sets the PORT environment variable for your Fly.io app. Please note that the port number you set should match the internal_port in the fly.toml file. This was mentioned in a Discord support thread (https://discord.com/channels/686873244791210014/1204929776272281641) where a community member changed the internal_port to 4321 in the fly.toml file and exposed it in the Dockerfile. In a production environment, the WASP_WEB_CLIENT_URL and WASP_SERVER_URL environment variables should be set to the URLs where your client and server apps are deployed, respectively. These URLs should not include a port number, as the port is managed by the platform (Fly.io in this case). For example:
WASP_WEB_CLIENT_URL=<https://<app-name>.netlify.app>
WASP_SERVER_URL=<https://<app-name>.fly.dev>
WASP_WEB_CLIENT_URL=<https://<app-name>.netlify.app>
WASP_SERVER_URL=<https://<app-name>.fly.dev>
Replace <app-name> with the name of your app. These commands set the URLs for your client and server apps. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @fred-123, 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?
fred-123
fred-1233mo ago
@kapa.ai so should i set a port for production or not? Can i ignore the warning from fly.io: 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 or should i change the port to 8080?
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- The warning message from Fly.io indicates that your application is not listening on the expected address and port. This could prevent your application from being reachable. In this case, you should set your application to listen on 0.0.0.0:8080 as suggested by the warning message. You can do this by setting the PORT environment variable to 8080 for your Fly.io app using the flyctl secrets set command:
flyctl secrets set PORT=8080
flyctl secrets set PORT=8080
This command sets the PORT environment variable for your Fly.io app to 8080. After setting the PORT environment variable, you should redeploy your application. If everything is set up correctly, your application should now be listening on 0.0.0.0:8080 and the warning message should no longer appear. Remember to also update the WASP_WEB_CLIENT_URL and WASP_SERVER_URL environment variables if you change the server's port number. These variables should be set to the URLs where your client and server apps are deployed, respectively. These URLs should not include a port number, as the port is managed by the platform (Fly.io in this case). For more information, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#set-up-a-flyio-app) on setting up a Fly.io app. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @fred-123, 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?
fred-123
fred-1233mo ago
@kapa.ai This didn't fix my problem. i ran flyctl secrets set -a myApp PORT=8080 and still get: 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 my fly-server.toml has this the same port: internal_port = 8080 I also tried running wasp build and redeploying using wasp deploy fly deploy but the issue persists.
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I'm sorry to hear that you're still experiencing issues. The warning message from Fly.io indicates that your application is not listening on the expected address and port. This could be due to a variety of reasons. Here are a few things you could try: 1. Check your application code: Ensure that your application is configured to listen on the port specified by the PORT environment variable. In Node.js, for example, you might have code like this:
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`Server is listening on port ${port}`);
});

const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`Server is listening on port ${port}`);
});

This code tells your application to listen on the port number specified by the PORT environment variable, or 3000 if PORT is not set. 2. Check your Dockerfile: If you're using Docker, make sure that your Dockerfile exposes the correct port with the EXPOSE instruction. For example:
EXPOSE 8080

EXPOSE 8080

This tells Docker that your application listens on port 8080. 3. Check your fly.toml file: Ensure that the internal_port in your fly.toml file matches the port your application is listening on. You mentioned that your fly.toml file has internal_port = 8080, which is correct if your application is listening on port 8080. 4. Redeploy your application: After making any changes, be sure to redeploy your application with wasp deploy fly deploy. If none of these suggestions help, I recommend reaching out to Fly.io support or checking their documentation (https://fly.io/docs/) for more information. They may be able to provide more specific guidance based on the details of your application and deployment configuration. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @fred-123, 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?
fred-123
fred-1233mo ago
@Wasp Team @Wasp Expert Did anybody else have that problem before? I couldn't find anything by searching the questions section.
wardbox
wardbox3mo ago
FWIW I see this error from time to time and ignore it. Are you experiencing any issues with your app because of it?
fred-123
fred-1233mo ago
I am not sure but I have a problem with google oauth and was thinking this might be related. I have set up oauth as per documenation and it works in dev. Once I am in production i don't get an error but it doesn't actually log the user in. it just throws me here and remains in the non-logged-in state: https://my-domain.com/auth/google/callback?state=txi7eNSF43AV-ttmxUMrle6wW9H7oF0G62DiBXXIC4Q&code=4%2F0AcvDMrBSBNSmr_-zc65jRQozC9ls6D_1dhOlK9aJNFTqrGcBmeuGbvk69KerrsxnhH2t7g&scope=email+profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&authuser=1&hd=madeupusername.net&prompt=consent
MY DOMAIN
MY DOMAIN
Give yourself a better website » MY DOMAIN
Give yourself a better website. Learn more about SEO and how to start your own blog. We also offer professional development services.
fred-123
fred-1233mo ago
@wardbox one thing i noticed. When running fly status -a myApp-server: it returns hostname: myapp-server.fly.dev instead of my custom domain.
wardbox
wardbox3mo ago
what's your redirect url for google auth in prod? it seems like it's going to https://my-domain.com still, it should point to the fly.dev domain
fred-123
fred-1233mo ago
In dev i was using http://localhost:3001/auth/google/callback as Authorized redirect URI and didn't set a authorized domain. In prod i have set my-domain.com as authorized domain and my-domain/auth/google/callback as Authorized redirect URI. So i should be using the myapp-server.fly.dev domain for authorized URI and myapp-server.fly.dev for Authorized domains? If yes then i got massively confused as it requried to set up google search Console "When a domain is used on the consent screen or in an OAuth client’s configuration, it must be pre-registered here. If your app needs to go through verification, please go to the Google Search Console to check if your domains are authorized. Learn more about the authorized domain limit."
wardbox
wardbox3mo ago
so the redirect uri should point to a domain you own/manage (in this case the fly.dev domain). unless you own my-domain.com, in which case :feelstenseman::Clap: with your current setup what you're telling it is, after auth, send them to my-domain.com (literally, this is not a placeholder) with the query parameters/path at the end. so you want to put in https://<myservice>-server.fly.dev/auth/google/callback <myservice> being the name of the server service in fly.io
fred-123
fred-1233mo ago
Thats what i have set it to. I have just swapped out my actual domain with my-domain.com so i can post it here without disclosing my domain. When I run fly status -a <myapp>-server it returns: Hostname = <myapp>-server.fly.dev In google i have set: Authorized redirect URIs: https://<myapp>-server.fly.dev/auth/google/callback and under oauth consent screen : Authorized domains: <myapp>-server.fly.dev I have set the client id and secrent through flyctl secrest set I have also set this as claude.ai suggested it could make it work: fly secrets set GOOGLE_CALLBACK_URL=https://<myapp>-server.fly.dev/auth/google/callback -a <myapp>-server It still doesn't work.
MEE6
MEE63mo ago
Wohooo @fred-123, you just became a Waspeteer level 5!
Want results from more Discord servers?
Add your server