Background
I’m working as a programmer for a company that has a complicated setup of repos, so what they’ve done is set up an EC2 instance with all of the necessary repos and config, and I ssh into it to work on their Python (Flask) backend code. I’ve been using Jetbrains Gateway as my IDE (it runs an IDE instance on the remote server and then you connect to it with a local client interface, so it looks just like PyCharm but the actual code and IDE features are being executed on the remote server)
Problem
I can’t figure out how to debug my code. I’ve used PyCharm’s debug feature before but I’m feeling lost in this setup.
What I’ve tried so far
I looked at the “Edit Configurations” view and saw that there’s a feature called “Python Debug Server”, which requires that I specify the IP address of my local machine and a port it is listening on, which the remote EC2 instance will then make a TCP connection to. I don’t have a static IP address and I’m not sure that my ISP allows incoming connections like that, so I was looking around online for a service that might help me with that, and saw that ngrok was mentioned in a few places.
I eventually got this working, and thought I’d write up how I did it for anyone else in the future who has this problem:
TLDR
- If you’re on a network that doesn’t allow incoming TCP connections to your computer, set up an ngrok TCP tunnel.
- Sign up for ngrok’s Personal plan ($10/mo).
- Go to https://ngrok.com/pricing, click on “ngrok for development” and then “Get started” under the “Personal” plan.
- Go to https://ngrok.com/pricing, click on “ngrok for development” and then “Get started” under the “Personal” plan.
- Sign up for ngrok’s Personal plan ($10/mo).
WIP WIP WIP I just lost an hour of work on this answer so I’m going to start again while saving my work more frequently.