[bug] Shopify CLI 3.85 port conflict from proxy server and dev server

Hey team,

We’ve been running this without any issues during the past 1-2 years.

We upgraded to Shopify CLI 3.85 and after the upgrade to the NEW APP DEV, this no longer works and there is a port conflict between the Rails dev server and the shopify app dev proxy server.

"clean": "rm -f web/.overmind.sock"

$: yarn run clean && shopify app dev --tunnel-url https://my-cloudflare-tunnel.com:5000

17:59:26 │    app-preview │ Preparing app preview on example.myshopify.com
17:59:26 │    graphiql    │ GraphiQL server started on port 3457
17:59:26 │    proxy       │ Proxy server started on port 5000

In a new terminal window:
$: cd ./web
$: bin/dev

web | .../ruby/3.4.2/lib/ruby/gems/3.4.0/gems/puma-6.6.0/lib/puma/binder.rb:342:in 'TCPServer#initialize': Address already in use - bind(2) for "::1" port 5000 (Errno::EADDRINUSE)

The port is already in use by the Shopify App Dev command even if I specify a custom –tunnel-url. If I don’t specify any port in the tunnel, it doesn’t work either.

The only way I was able to run the rails server and the Shopify App Dev command is when I specify a different port in the Cloudflare tunnel url, for example: $: yarn run clean && shopify app dev --tunnel-url https://my-cloudflare-tunnel.com:4000.

Anyway, this was working fine until the upgrade, however, this looks new and I couldn’t find any documentation for it:

17:59:26 │    proxy       │ Proxy server started on port 5000

Thank you!

Hi @app , I think there is some confusion about what port you need to use in the tunnel url flag.

The error message makes sense: you can’t use the same port for two things: Rails and the CLI.

If you use port 5000 on your rails dev server, you need to choose a different one for your tunnel and use that one in –-tunnel-url, for instance 5001.

You can tell the CLI in which port your ruby app is running by setting the port property in the web.toml file.

Thank you @Isaac-Shopify,

A few months ago, I was using the shopify.web.toml with the following configuration, however, I ditched this approach because I wanted to see all my rails processes, workers and errors better with overmind.

type="frontend"

[commands]
dev = "bin/dev"

Running a different port in the tunnel works, however, I’m not running anything on this port. How come it was working fine before the upgrade? Is this proxy server new? If yes, what does it do?

shopify app dev --tunnel-url https://my-cloudflare-tunnel.com:4000 and shopify app dev --tunnel-url https://my-cloudflare-tunnel.com:5001

Thank you so much again!

You can still run your Rails server independently, just setup your toml like:

type="frontend"

[commands]
dev = "echo 1"
port = 5000

The CLI won’t run your rails app, but it will know that it is in port 5000.

The proxy is not new, it’s been there for years and is necessary to handle the dev session.
The CLI will start a proxy in whatever port you pass via —-tunnel-url, and it must be an unused port.

If it worked before, it probably was just luck, I think starting rails first and then the CLI could “work”. But internally the CLI won’t be able to serve any extension because the port is not really free.

Thanks a lot @Isaac-Shopify!