Connect to services using Private Networks

Project ID: 1790d4a8-0e32-4b4e-bf67-6ce23d7ae9e1

I'm trying to connect my main project (Node.js) to a Python API hosted in the same Railway project, according to the logs, my Python project is listening to and is online on inswapper.railway.internal.

I'm not really sure how to connect to the Python API from the main project and most probably misunderstanding how private networking works, so far I tried to make an Axios post request to the endpoint but that returns an ECONNREFUSED error:

AxiosError.call(axiosError, error.message, code, config, request, response);
AxiosError: connect ECONNREFUSED
at Function.AxiosError.from (/app/node_modules/axios/lib/core/AxiosError.js:89:14)
at RedirectableRequest.handleRequestError (/app/node_modules/axios/lib/adapters/http.js:593:25)
at RedirectableRequest.emit (node:events:513:28)
at RedirectableRequest.emit (node:domain:489:12)
at ClientRequest.eventHandlers.<computed> (/app/node_modules/follow-redirects/index.js:14:24)
at ClientRequest.emit (node:events:513:28)
at ClientRequest.emit (node:domain:489:12)
at Socket.socketErrorListener (node:_http_client:494:9)
at Socket.emit (node:events:513:28)
at Socket.emit (node:domain:489:12) {
port: 3001,
address: '',
syscall: 'connect',
errno: -111,
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
adapter: 'http',
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: { FormData: [Function], Blob: null },
validateStatus: [Function: validateStatus],
headers: Object [AxiosHeaders] {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
'User-Agent': 'axios/1.5.0',
'Content-Length': '174',
'Accept-Encoding': 'gzip, compress, deflate, br'
method: 'post',
url: '';,
data: '{"source":"","target":"";}'

I also attempted to make a request to http://inswapper.railway.internal:3001/swapper but that resulted in an error as well.

This is the code that I use to make requests to the Python API:

axios.post("http://" + process.env.INSWAPPER + "/swapper", {
        source: body.source,
    target: body.replace,
}).then((data) => {
    if (data.data) {
        return response.status(200).json({
            error: false,
            output: data.data.output,

(I've set process.env.INSWAPPER to both and inswapper.railway.internal:3001, none worked)

Also, my Python API takes around 12 minutes to build, it keeps re-installing dependencies (around 5GB I believe) and making deployments slower, is this normal or am I once again doing something wrong?
I have some suggestions before someone smarter than me comes and tells you the answer 🙂

Although it says HTTP you could try https instead of http.
Also have your app listen on the railway provided port environment variable if you aren't already.
Just tried, still the same error as above and as far as im aware the port is set correctly.
thanks for the suggestions though!
You should bind your server on :: instead of, as privnets work over IPv6
If im correct, the server is binded to ::, unless im misunderstanding something...

if __name__ == "__main__":
    port_env = os.getenv("PORT", default = 3001);
    print(f"Application is listening to port {port_env}");

        app = app,
        host = "::",
        port = port_env

Oops, nevermind, misread your message

Looking for more? Join the community!

Recommended Posts
Upload FilesGood morning, I have 4 gigabytes of image files, my application is connected to Git, and I can't uplFiles on mounted volume not available after redeployI did a fresh deploy of @Brody 's Payload CMS template (https://github.com/brody192/payload-cms-tempCan't manually fill MySQLNone of the options i've tried works. I can still create dbs and populate them when connecting throuReferenced variables are emptyIf I hardcode the url in env variables, the deployment is successful, however using a reference to aSetup a monorepoHey guys, I'm using yarn workspaces and turborepo. I tried setting up the build command to "yarn turCan't start Remotion serverWhenever I try to use the Remotion server it cannot open the browser process and shows me this errorRecover a file inside a deploymentBy mistake I left a sqlite file inside a deployment and made a lot of updates to the database on thaDeployment Failed during build processI'm encountering issues while trying to build my Vue 3 and TypeScript project on Railway using NixpaBuild failing without errorMy build is failing to deploy without any error. Its just saying the container failed to start. The Cloudflare detected but not redirectingI've put the the right dns settings in cloudflare NS into godaddy. see screenshot which should poinFailed to authenticate to mongodbDeploying a MongoDB database from the UI, automatically creates a database named "test" if you connePrivate NPM Registry (GitHub)I'm using Yarn 3, GitHub Packages, and NodeJS. I am testing a deploy with `railway up` and when it gDjango advice neededHello good people, i would like to know how can i get some support for Railway? I started with a basUpdate TypebotHello, how i can update my project of typebot without lose all? i am new user in railwayWho deleted our database?I am writing to inquire about the recent deletion of the MySQL database in our account, we noticed Dockerbuild failes with no matching versionI attached the error and the dockerfile. The dockerfile locally runs withouth error but on railway ifailed opening connection to sql: default addr for networkHi, I am trying to deploy my golang web service which connects to mysql. I have added the mysql url Deploying Meilisearch template does not workI have a running project, If I click on new -> template -> Meili then a new service is created. HoweDeploy Flutter, error on buildHelp me! How do I deploy my flutter app on railway?Strapi crashes out of nowhereHello, my Strapi app sometimes crashes out of nowhere. This is not very good, because I have a prod