Cannot run shopify login with Shopify CLI (no browser). What is the workaround?

Topic summary

Main issue: Logging into Shopify CLI on a remote, headless Ubuntu server fails because the OAuth callback targets localhost (127.0.0.1:3456), which isn’t accessible without a browser on the server.

Early attempts and caveats:

  • Using Python’s webbrowser module was suggested, but clarified as ineffective in remote SSH contexts (callback still to 127.0.0.1 on the server).
  • Putty/SSH local port forwarding to 3456 was used; questions arose about text-based browsers and CAPTCHA.

Working solutions:

  • SSH port forwarding: create a local tunnel to the server’s callback port, e.g. “ssh -L localhost:3456:localhost:3456” (optional also port 9292 for dev), enabling local browser to complete the flow.
  • “wget callback” method (confirmed by multiple users):
    1. Run CLI until it shows the “Log in to Shopify Partners” URL.
    2. Open that URL in a local browser (already logged into Partners).
    3. When it redirects and fails with “127.0.0.1 refused to connect,” copy the full “http://127.0.0.1:3456/?code=…” URL.
    4. On the server, execute: wget ‘http://127.0.0.1:3456/?code=…’.
    5. Authentication completes in the CLI session.

Notes: Screenshots of Putty tunnel and CLI banner are referenced; commands are central.

Status: The wget-based workflow is validated; Python browser approach is rejected. One report of CLI 3.x exiting post-login remains unresolved.

Summarized with AI on December 23. AI used: gpt-5.

I’ve installed Shopify CLI to try theme app extension. But I am working remotely from my PC to Ubuntu 18.04 dev server. When I run Shopify login, CLI gives me a URL to paste on the browser. But the redirect URI in this URL starts with 127.0.0.1. The link showed the login screen but it failed after I clicked my account.

Even I can login, I am not sure if I can scaffold a theme app extension since my app is not created with CLI.

I understand that Shopify wants to push all themes to upgrade to OS 2.0. My app is Python / Django. Now the CLI is installed with rbenv and >= Ruby 2.7. And it requires local development. Can you give me a less opinionated choice or workaround?

My app just uploads 4 liquid files to the theme. And the liquid files are using theme sections to make customizations.

4 Likes

Did you figure this out? I’m trying to do the exact same thing. I have ubuntu VM on AWS with no browser. Thanks!

1 Like

Just use python built-in webbrowser module to visit the link.

I ended up creating a tunnel for port 3456 using Putty:

6 Likes

Could you explain how to have the Shopify CLI open the that particular text editor? When I enter Shopify login, a text browser opens automatically in the text editor, so I can’t solve the captcha, which requires javascript. Does python’s browser solve the captcha issue?

Do you use the command “shopify login”? If so , how does this solve the browser issue? Could you please explain it a bit further?

Run ssh -N -L localhost:3456:localhost:3456 [email removed]

3 Likes

Is it still ok to use a Tunnel in Putty? I try the same way for CLI 3.x running npm run dev. Copy the login link to the browser. Chrome tells me log in successfully. But the CLI exits on its own. Anyone is trying CLI on a remote server?

This is not correct and shouldn’t be an accepted solution. The question indicates, that they are working remotely (which probably indicates SSH tunnel). The Python webbrowser module does not help, when going to the link from remote terminal. The login page still redirects to 127.0.0.1.

3 Likes

Worked for me without using “-N”. If you want to ssh tunnel the dev server also just use “ssh -L localhost:3456:localhost:3456 -L localhost:9292:localhost:9292 @<server_ip>”

2 Likes

I was able to figure this out thanks to a post here: https://blog.klaudsol.com/how-to-run-shopify-cli-in-aws-cloud-9/

I was able to authenticate a Shopify partner account on “Ubuntu 22.04.3 LTS” AWS EC2 instance. Steps below:

  1. Install Node.js and npm. I used Node Version Manager (Option 3 here)
  2. Install Shopify CLI with theme: npm install -g @Shopify_77 /cli @Shopify_77 /theme
  3. Check if it is installed: shopify version
  4. Chose a folder and build app: npm init @Shopify_77 [email removed]
  5. Shopify App structure created successfully, and at this point you need to initiate a login to Shopify partner account and authenticate. Because I am creating an extension app I run: npm run shopify app generate extension
  6. Wait for the “Auto-open timed out” message to appear after the banner:
    To run this command, log in to Shopify Partners.
![Misho_0-1700203658181.png|72x72](upload://g2xZY0cQQelcY9AiPNbkYdC59Ye.png) Press any key to open the login page on your browser Auto-open timed out. Open the login page: Log in to Shopify Partners ( http://accounts.shopify.com/oauth/authorize?client_id=.... ) 7. Copy the full URL in the brackets after "Log in to Shopify Partners" text 8. Paste it in a browser on your local PC (preferably in a window already logged in to a Shopify partner account) 9. You will get a "This site can’t be reached 127.0.0.1 refused to connect." page. Copy the generated URL. It needs to have a URL starting with "http://127.0.0.1:3456/?code=...." . BTW generating the code did not work from the first time for me. 10. Open a new SSH session to your AWS EC2 instance. Paste the full URL in a wget command. Like: wget 'http://127.0.0.1:3456/?code=' . Do not forget the single quotes around the link. 11. Done. At the first SSH session screen you can see the authentication process finalizing.
5 Likes

This method worked for me. Thanks a lot!

This is the way.