I've inherited a repository that contains both a NodeJS part and a Python part. The project structure is such that the NodeJS is at the root of the repository, and the Python pieces are in a Python folder:
root
|- app
|- some.js
|- files.js
|- Python
|- other.py
|- files.py
I've set up a Heroku dyno to serve both a Python server and a NodeJS server, by doing this in my Procfile (based loosely on this older article):
web: npm start
python: sh -c 'cd ./Python/ && export PYTHONPATH=. && python other.py'
The python project is set up to use port 2001. It's a Bottle application and on starting the server I pass in this port (taken from the Heroku settings).
In my logging, I can see that both are started successfully. Simplified:
Bottle v0.12.13 server starting up (using WaitressServer())...
Listening on http://localhost:2001/
Server running at: http://<guid>:7667
When I request the root of my application, I get a reply from the NodeJS server. However, for some routes, I want to make a call to the Python part. I've succesfully done this locally, by using Node's http. However, when doing this on Heroku, I receive the following error:
connect ECONNREFUSED 127.0.0.1:2001
When I run this project locally in Heroku (via the CLI tool heroku local), it works perfectly. Any ideas on how I can get this to work?