1

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?

1 Answer 1

1

Finally found it. Dynos can't communicate with each other via HTTP, only via queues. I can't find it in the docs anymore, but they state it somewhere.

So I changed my Procfile to only run one dyno:

web: npm start & sh -c 'cd ./Python/ && export PYTHONPATH=. && python other.py'

Now I can make my call to 127.0.0.1:2001 without any problems.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.