Server is not found with my App with the host and port properly set in fly.toml and Dockerfile

Although I have set everything properly in my Dockerfile, refer to my Dockerfile:

# Use an official node runtime as a parent image
FROM node:14-alpine

# Set the working directory in the container
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install any needed packages
RUN npm install

# Clean npm cache
RUN npm cache clean --force

# Copy the rest of the application code
COPY . .

# Copy the .env file
COPY .env .env

# Build the app for production and print logs if it fails
RUN npm run build || { echo "Build failed"; exit 1; }

# Install serve to serve the build
RUN npm install -g serve

# Make port 8080 available to the world outside this container
EXPOSE 8080

# Start the app
CMD ["serve", "-s", "build", "-l", "8080"]

and refer to my fly.toml as well:

app = "object-detection-frontend"

[env]
PORT = "8080"

[[services]]
  internal_port = 8080
  protocol = "tcp"

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.http_checks]]
    interval = "10s"
    grace_period = "5s"
    method = "get"
    path = "/"
    protocol = "http"
    restart_limit = 0
    timeout = "2s"

I was to build my frontend image with the command: docker build -t frontend_react . --add-host my-hostname=0.0.0.0 and deploy the image with that command: flyctl deploy -a object-detection-frontend --local-only --image frontend_react.

When the image is finally pushed and deployed, even though the health checks were all fine, the app at https://object-detection-frontend.fly.dev does not get served correctly and it always says: ##Server is not found## with the message: “Hmm. We’re having trouble finding that site.” on firefox.

Any ideas about where the problem could be.

Don’t you need to put your host somewhere in there? 0.0.0.0 or [::] (or just ::) for ipv6

Yeah I have run this command in a couple of ways before, both of which did not work.

  • Like so: CMD [“serve”, “-s”, “build”, “–network”, “0.0.0.0”, “-l”, “8080”]
  • and so: CMD [“serve”, “-s”, “build”, “-n”, “0.0.0.0”, “-l”, “8080”]
    They would result in the same thing. Server is still not recognizing my app.

Hi @OmarMo7 ,

It looks like your app does not have an IP address assigned, therefore it’s not reachable from the Internet and its hostname is also not published because of this.

Please try adding an IP address; a shared one will do nicely and has no extra cost.

fly ips allocate-v4 --shared.

Usually a shared IP is assigned on first deploy, but if you first did a deploy with no services or the initial deploy failed, this may not have been done automatically.

  • Daniel
1 Like

Are you sure -n and -network are valid flags? From the docs, -n is “Do not copy the local address to the clipboard”… whatever that means.
Try "0.0.0.0:8080". But as roadmr mentioned, you’re missing an IP addres.

1 Like

I would have never known this IP address thing in a million years on my own.
ChatGPT itself was no help with that.
The site opened after hitting the command: fly ips allocate-v4 --shared -a my-app-name

Thanks khuezy and Daniel.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.