Getting 'Connection was reset' error on Shopify App

I’ve been following the Shopify guide here on how to host an app for Shopify.

  • I’ve checked the logs, no errors.
  • Updated Shopify Partner details to match the Fly.io callback URL.

Every time I try to install the app to a development site in Shopify Partners for testing, after a while I get the error ‘The connection was reset’. Not sure where to go from here.

I’m not super familiar with shopify apps. Where are you seeing “The connection was reset” exactly?

Could you share some of your fly.toml? If the connection is reset navigating directly to your app its possible there’s a missing piece of configuration.

File below:

# fly.toml file generated for mn-checkout-discounts on 2023-04-03T09:39:27+10:00

app = "mn-checkout-discounts"
kill_timeout = 0
primary_region = "syd"

[env]
  HOST = "https://mn-checkout-discounts.fly.dev/"
  PORT = "8081"
  SCOPES = "write_products,write_discounts,unauthenticated_read_product_listings,read_price_rules,read_discounts"
  SHOPIFY_API_KEY = "################"

[[services]]
  internal_port = 8081

I’m seeing the connection reset error after a period of time when navigating to the app from Shopify Partners. I go to install it, it requests the HOST url, and then ‘connection reset’ appears after about 30 seconds…

Hey there,

Looks like you’re missing services in your fly.toml. The Shopify docs are a little confusing there, but you do need to expose services as well as configuring the internal_port. Try this:

app = "mn-checkout-discounts"
kill_timeout = 0
primary_region = "syd"

[env]
  HOST = "https://mn-checkout-discounts.fly.dev/"
  PORT = "8081"
  SCOPES = "write_products,write_discounts,unauthenticated_read_product_listings,read_price_rules,read_discounts"
  SHOPIFY_API_KEY = "################"

[[services]]
  internal_port = 8081

[[services.ports]]
  handlers = ["http"]
  port = 80
  force_https = true  # optional
[[services.ports]]
  handlers = ["tls", "http"]
  port = "443"
1 Like

That has worked. The app seems to be working when called now.

However, why I go to install the app for testing through Shopify Partners, I am getting the error: “Oauth error invalid_request: The redirect_uri is not whitelisted”.

The App settings I have are:

So that should technically be working, but Shopify is still having an issue whitelisting the URL.

I wonder if the trailing slash might be throwing this off - I stumbled across this discussion on their forums: Solved: Re: Oauth error invalid_request: The redirect_uri is not whitelisted - Shopify Community

I’ve solved the issue. I noticed the redirect URL generated was coming back with a double protocol (i.e. https://https://). The Shopify App requires a hostname variable, but for some reason does not want the URL protocol in the hostname. Removing ‘https://’ in the app allowed everything to flow through.

2 Likes

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