Shopify CLI gives an Error while using it to create an extension!

Hmm strange. I wonder if it’s throwing yet another error type and not the ECONNREFUSED or ETIMEDOUT.

You can edit the Shopify-CLI code to skip the port check if you know that ports open. It’s clearly a hack-fix and only a temporary solution.

On line 47 of shopify-cli\lib\project_types\extension\commands\serve.rb

Replace

def find_available_port(runtime_configuration)
        return runtime_configuration unless specification_handler.choose_port?(@ctx)

        chosen_port = Tasks::ChooseNextAvailablePort
          .call(from: runtime_configuration.port)
          .unwrap { |_error| @ctx.abort(@ctx.message("serve.no_available_ports_found")) }
        runtime_configuration.tap { |c| c.port = chosen_port }
      end

with

def find_available_port(runtime_configuration)
        puts 'Hack fix is in place.'
        return runtime_configuration
      end

If you’ve edited the correct file you should see “Hack fix is in place.” in the terminal when you run ‘shopify extension serve’, and hopefully it works.