0

I have two microservice (using nest.js) deployed on heroku. When I try to connect I get this error: Error: getaddrinfo ENOTFOUND https://URL.herokuapp.com

This is the my way for connect to microsrevice.

{
                imports: [ConfigModule],
                inject: [ConfigService],
                name: 'CURRENCY_SERVICE',
                useFactory: (configService: ConfigService) => {
                    return {
                        transport: Transport.TCP,
                        options: {
                            host: configService.services.currency.host,
                            port: configService.services.currency.port,
                        },
                    }
                },
            }

I couldn't find the port number heroku assign. So I just log the port number after app is up and copied to .env file.

This is my .env file

CURRENCY_SERVICE_HOST=https://URL.herokuapp.com
CURRENCY_SERVICE_PORT=53294 # I copied this port number from view logs section on heroku 

Also I tried access without port but still can't connect. I can connect on localhost by he way. I just need to find correct connection credentials please help me

Akif Kara
  • 442
  • 6
  • 14
  • Is the deployed microservice working? Try with pure [js](https://gist.github.com/jrichardsz/6b6f2c0d052253f7b76a35427bdff1b9) instead angular and share us the result – JRichardsz Jan 07 '23 at 23:50
  • I think heroku doesn't support tcp support this is reason why this error occurs – Akif Kara Jan 08 '23 at 09:57
  • i understand you deploy 2 app on heroku and heroku give you 2 domain to access your app like app1.heroku.com and app2.heroku.com. So you want to call an API in app2 from app1 right ? – Khanh Le Tran Jan 10 '23 at 07:13
  • 1
    First you want to try accessing those URLs in the browser, and see if they resolve. – Fowotade Babajide Jan 10 '23 at 12:48
  • It's not entirely clear if your microservices need to talk to each other or if you're accessing both from a front-end application. Please add more details about the client and the server environments. – Gui LeFlea Jan 10 '23 at 18:48

1 Answers1

0

This is the first and the most basic test. Try accessing those URLs in the browser and see if the apps are running as expected and if they resolve. If your API URI is https://URL.herokuapp.com/api/v0/endpoint Open the app API URI in a browser to ensure that it is working.

Next, presuming both services are back-end nodejs apps that need to talk to each other via server-to-server API calls, you want to ensure that communication between them is working on Heroku.

It seems like you're on the right track with troubleshooting and logging this step, but you definitely don't want to use the internal port number. You do want to use the public URL https://URL.herokuapp.com. When using HTTPS, it's always going to be on port 443.

Please take a look at this answer for additional help with configuring, deploying, and running microservices on Heroku. How to deploy microservices on Heroku

Hopefully, this helps. Good luck!

Gui LeFlea
  • 795
  • 3
  • 12
  • I tried everything also I get support from heroku but still can't connect tcp. I'm sure all credentials are correct but not return response in 30 sec – Akif Kara Jan 11 '23 at 10:50
  • What about HTTP? Can you view https://URL.herokuapp.com in the browser? What do you see? – Gui LeFlea Jan 11 '23 at 17:07