2 years ago
Hello everyone!
I'm currently working on a project that involves two backends hosted on Railway:
Main Backend: Built with NestJS, exposed to the public.
Secondary Backend: Built with Python Flask, not exposed to the public, intended to communicate with the NestJS backend through private networking.
Both backends are part of the same project on Railway, i've configured the Flask backend's URL in the NestJS settings as follows:
http://${{flask.RAILWAY_PRIVATE_DOMAIN}}:${{flask.PORT}}This results in the URL: [http://flask.railway.internal:5000](http://flask.railway.internal:5000)
The Flask server is up & running on PORT 5000, deploy logs:
[2024-03-29 11:55:49 +0000] [7] [INFO] Starting gunicorn 20.0.4
[2024-03-29 11:55:49 +0000] [7] [INFO] Listening at: http://0.0.0.0:5000 (7)
[2024-03-29 11:55:49 +0000] [7] [INFO] Using worker: sync
[2024-03-29 11:55:49 +0000] [11] [INFO] Booting worker with pid: 11Issue:
When triggering an action that triggers NestJS to communicate with the Flask backend, I encounter an issue where the NestJS fails to connect to the Flask backend.
NestJS Deploy Logs:
Error manipulating image: AxiosError: connect ECONNREFUSED fd12:a038:457a::76:c197:****:5000
port: 5000
address: 'fd12:a038:457a::76:c197:****'It seems like the IPV6 address from the private network is resolved correctly.
Python Flask main.py:
if __name__ == "__main__":
app.run(host="::", debug=True, port=os.getenv("PORT", default=5000))NestJS main.ts:
const app = await NestFactory.create(
AppModule,
new FastifyAdapter({ logger: true }), // Enable Fastify's logger
);
const configService = app.get(ConfigService);
const PORT = configService.get('PORT', { infer: true });
// Listen on all IPv6 addresses
await app.listen(PORT, '::', () => {
app.get(Logger).log(`Listening on IPv6 port ${PORT}`);
});Any help would be greatly appreciated!
Thank you! 🙏
3 Replies
````
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "gunicorn -b '[::]:'$PORT main:app",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}}
```