Hi, running into a bug where my rails app is deployed but the content of my app is unreachable:
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
-----------------*--------------------------------------
/goapp/app | [::]:8080
/.fly/hallpass | [fdaa:2:da27:a7b:93:3663:cc19:2]:22
I’ve used similar topics to figure out that I needed to update my fly.toml and Dockerfile to use the default Rails port of 3000.
# fly.toml app configuration file generated for alex-bunty on 2023-08-25T13:16:32-04:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = "alex-bunty"
primary_region = "iad"
[build]
image = "flyio/hellofly:latest"
[env]
PORT = "3000"
[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
# syntax = docker/dockerfile:1
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.2.2
FROM ruby:$RUBY_VERSION-slim as base
# Rails app lives here
WORKDIR /rails
# Set production environment
ENV RAILS_ENV="production" \
BUNDLE_WITHOUT="development:test" \
BUNDLE_DEPLOYMENT="1"
# Update gems and bundler
RUN gem update --system --no-document && \
gem install -N bundler
# Throw-away build stage to reduce size of final image
FROM base as build
# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential pkg-config
# Install application gems
COPY --link Gemfile Gemfile.lock ./
RUN bundle install && \
bundle exec bootsnap precompile --gemfile && \
rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git
# Copy application code
COPY --link . .
# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile
# Final stage for app image
FROM base
# Install packages needed for deployment
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libsqlite3-0 && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /rails /rails
# Run and own only the runtime files as a non-root user for security
RUN useradd rails --create-home --shell /bin/bash && \
mkdir /data && \
chown -R rails:rails db log storage tmp /data
USER rails:rails
# Deployment options
ENV DATABASE_URL="sqlite3:///data/production.sqlite3" \
RAILS_LOG_TO_STDOUT="1" \
RAILS_SERVE_STATIC_FILES="true"
# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
VOLUME /data
CMD ["./bin/rails", "server -b 0.0.0.0"]
The two types of errors in my logs are:
[error] 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)
[error] could not find a good candidate within 90 attempts at load balancing
As an additional check I even edited my puma.rb file to bind ‘0.0.0.0’ to my port (just to remove any possible instance of 127.0.0.1). I realize this shouldn’t matter as the puma server is used for the development environment and not production environment, but I just felt I needed to make the change for sanity’s sake. I have no issues running the app in the local development environment.
I was reading about the arguments for CMD in the Dockerfile and thought that maybe the command “server” was starting up the unreachable 127.0.0.1:3000, so I attempted to change that by using the command "server -b 0.0.0.0” to bind 0.0.0.0 to the port (though from my reading it seems that Docker defaults to 0.0.0.0 and people usually have the opposite issue). Still receiving the same result after making this change.
Is there somewhere else in my codebase I should inspect to configure my app to listen on 0.0.0.0:3000 ?
This is my entire logs:
2023-08-25T17:16:39.232 runner[148e1e7a322928] iad [info] Pulling container image registry-1.docker.io/flyio/hellofly:latest
2023-08-25T17:16:39.356 runner[148e1e7a322928] iad [info] Successfully prepared image registry-1.docker.io/flyio/hellofly:latest (124.627483ms)
2023-08-25T17:16:39.915 runner[148e1e7a322928] iad [info] Configuring firecracker
2023-08-25T17:16:40.367 app[148e1e7a322928] iad [info] [ 0.049135] PCI: Fatal: No config space access function found
2023-08-25T17:16:40.582 app[148e1e7a322928] iad [info] INFO Starting init (commit: b437b5b)...
2023-08-25T17:16:40.660 app[148e1e7a322928] iad [info] INFO Preparing to run: `/goapp/app` as root
2023-08-25T17:16:40.664 app[148e1e7a322928] iad [info] INFO [fly api proxy] listening at /.fly/api
2023-08-25T17:16:40.751 app[148e1e7a322928] iad [info] 2023/08/25 17:16:40 listening on [fdaa:2:da27:a7b:93:3663:cc19:2]:22 (DNS: [fdaa::3]:53)
2023-08-25T17:16:41.098 app[148e1e7a322928] iad [info] [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
2023-08-25T17:16:41.098 app[148e1e7a322928] iad [info] [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
2023-08-25T17:16:41.098 app[148e1e7a322928] iad [info] - using env: export GIN_MODE=release
2023-08-25T17:16:41.098 app[148e1e7a322928] iad [info] - using code: gin.SetMode(gin.ReleaseMode)
2023-08-25T17:16:41.100 app[148e1e7a322928] iad [info] [GIN-debug] Loaded HTML Templates (2):
2023-08-25T17:16:41.100 app[148e1e7a322928] iad [info] -
2023-08-25T17:16:41.100 app[148e1e7a322928] iad [info] - hellofly.tmpl
2023-08-25T17:16:41.100 app[148e1e7a322928] iad [info] [GIN-debug] GET / --> main.handleIndex (3 handlers)
2023-08-25T17:16:41.100 app[148e1e7a322928] iad [info] [GIN-debug] GET /:name --> main.handleIndex (3 handlers)
2023-08-25T17:16:41.100 app[148e1e7a322928] iad [info] [GIN-debug] Listening and serving HTTP on :8080
2023-08-25T17:16:51.718 runner[e286d20b934428] iad [info] Pulling container image registry-1.docker.io/flyio/hellofly:latest
2023-08-25T17:16:51.899 runner[e286d20b934428] iad [info] Successfully prepared image registry-1.docker.io/flyio/hellofly:latest (180.546361ms)
2023-08-25T17:16:52.449 runner[e286d20b934428] iad [info] Configuring firecracker
2023-08-25T17:16:52.780 app[e286d20b934428] iad [info] [ 0.042174] PCI: Fatal: No config space access function found
2023-08-25T17:16:52.987 app[e286d20b934428] iad [info] INFO Starting init (commit: b437b5b)...
2023-08-25T17:16:53.042 app[e286d20b934428] iad [info] INFO Preparing to run: `/goapp/app` as root
2023-08-25T17:16:53.047 app[e286d20b934428] iad [info] INFO [fly api proxy] listening at /.fly/api
2023-08-25T17:16:53.124 app[e286d20b934428] iad [info] 2023/08/25 17:16:53 listening on [fdaa:2:da27:a7b:92:9cee:ee75:2]:22 (DNS: [fdaa::3]:53)
2023-08-25T17:16:53.403 app[e286d20b934428] iad [info] [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
2023-08-25T17:16:53.403 app[e286d20b934428] iad [info] [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
2023-08-25T17:16:53.403 app[e286d20b934428] iad [info] - using env: export GIN_MODE=release
2023-08-25T17:16:53.403 app[e286d20b934428] iad [info] - using code: gin.SetMode(gin.ReleaseMode)
2023-08-25T17:16:53.404 app[e286d20b934428] iad [info] [GIN-debug] Loaded HTML Templates (2):
2023-08-25T17:16:53.404 app[e286d20b934428] iad [info] - hellofly.tmpl
2023-08-25T17:16:53.404 app[e286d20b934428] iad [info] -
2023-08-25T17:16:53.404 app[e286d20b934428] iad [info] [GIN-debug] GET / --> main.handleIndex (3 handlers)
2023-08-25T17:16:53.404 app[e286d20b934428] iad [info] [GIN-debug] GET /:name --> main.handleIndex (3 handlers)
2023-08-25T17:16:53.404 app[e286d20b934428] iad [info] [GIN-debug] Listening and serving HTTP on :8080
2023-08-25T17:17:09.477 proxy[148e1e7a322928] iad [error] 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)
2023-08-25T17:17:09.503 proxy[e286d20b934428] iad [error] 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)
2023-08-25T17:17:19.855 proxy[148e1e7a322928] iad [error] 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)
2023-08-25T17:17:20.861 proxy[e286d20b934428] iad [error] 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)
2023-08-25T17:17:29.937 proxy[e286d20b934428] iad [error] 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)
2023-08-25T17:17:38.821 proxy[148e1e7a322928] iad [error] 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)
2023-08-25T17:17:40.736 proxy[e286d20b934428] iad [error] 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)
2023-08-25T17:17:45.744 proxy[148e1e7a322928] iad [error] 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)
2023-08-25T17:17:47.748 proxy[e286d20b934428] iad [error] 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)
2023-08-25T17:17:56.617 proxy[148e1e7a322928] iad [error] 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)
2023-08-25T17:17:58.623 proxy[e286d20b934428] iad [error] 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)
2023-08-25T17:18:07.491 proxy[148e1e7a322928] iad [error] 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)
2023-08-25T17:18:18.455 proxy[148e1e7a322928] iad [error] 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)
2023-08-25T17:18:19.434 proxy[e286d20b934428] iad [error] 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)
2023-08-25T17:18:30.419 proxy[e286d20b934428] iad [error] 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)
2023-08-25T17:18:34.371 proxy[e286d20b934428] iad [error] could not find a good candidate within 90 attempts at load balancing
2023-08-25T17:24:20.533 proxy [148e1e7a322928] iad [info] Downscaling app alex-bunty in region iad from 2 machines to 1 machines. Automatically stopping machine 148e1e7a322928
2023-08-25T17:24:20.539 app[148e1e7a322928] iad [info] INFO Sending signal SIGINT to main child process w/ PID 256
2023-08-25T17:24:21.223 app[148e1e7a322928] iad [info] INFO Main child exited with signal (with signal 'SIGINT', core dumped? false)
2023-08-25T17:24:21.224 app[148e1e7a322928] iad [info] INFO Starting clean up.
2023-08-25T17:24:21.227 app[148e1e7a322928] iad [info] WARN hallpass exited, pid: 257, status: signal: 15 (SIGTERM)
2023-08-25T17:24:21.234 app[148e1e7a322928] iad [info] 2023/08/25 17:24:21 listening on [fdaa:2:da27:a7b:93:3663:cc19:2]:22 (DNS: [fdaa::3]:53)
2023-08-25T17:24:22.226 app[148e1e7a322928] iad [info] [ 461.900368] reboot: Restarting system
2023-08-25T17:26:26.957 proxy [e286d20b934428] iad [info] Downscaling app alex-bunty in region iad from 1 machines to 0 machines. Automatically stopping machine e286d20b934428
2023-08-25T17:26:26.960 app[e286d20b934428] iad [info] INFO Sending signal SIGINT to main child process w/ PID 256
2023-08-25T17:26:27.707 app[e286d20b934428] iad [info] INFO Main child exited with signal (with signal 'SIGINT', core dumped? false)
2023-08-25T17:26:27.708 app[e286d20b934428] iad [info] INFO Starting clean up.
2023-08-25T17:26:27.708 app[e286d20b934428] iad [info] WARN hallpass exited, pid: 257, status: signal: 15 (SIGTERM)
2023-08-25T17:26:27.709 app[e286d20b934428] iad [info] 2023/08/25 17:26:27 listening on [fdaa:2:da27:a7b:92:9cee:ee75:2]:22 (DNS: [fdaa::3]:53)
2023-08-25T17:26:28.703 app[e286d20b934428] iad [info] [ 575.959218] reboot: Restarting system