I'm trying to call abha-services from parchaa-ndhm but I'm encountering the error. I've even made a network named my_network and all the containers are in my_network but the call from parchaa-ndhm is not reaching to abha-services. what can be wrong in this docker compose file or is there anything to do with nestjs
parchaa-ndhm | [Nest] 55 - 03/09/2023, 1:58:05 PM ERROR [ExceptionsHandler] connect ECONNREFUSED 127.0.0.1:8081
parchaa-ndhm | Error: connect ECONNREFUSED 127.0.0.1:8081
parchaa-ndhm | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
below is my docker compose file
version: "3.7"
services:
abha-services:
platform: linux/amd64
build:
context: .
dockerfile: ./apps/abha-services/Dockerfile
container_name: abha-services
hostname: abha-services
command: npm run start abha-services
env_file:
- .env
ports:
- '8081:8081'
networks:
- my_network
parchaa-ndhm:
platform: linux/amd64
build:
context: .
dockerfile: ./apps/parchaa-ndhm/Dockerfile
container_name: parchaa-ndhm
hostname: parchaa-ndhm
command: npm run start parchaa-ndhm
env_file:
- .env
ports:
- '1506:1506'
links:
- abha-services
- user-services
networks:
- my_network
user-services:
platform: linux/amd64
build:
context: .
dockerfile: ./apps/user-services/Dockerfile
container_name: user-services
hostname: user-services
command: npm run start user-services
env_file:
- .env
depends_on:
- postgres
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
ports:
- '8082:8082'
networks:
- my_network
postgres:
image: postgres:13-alpine
restart: always
container_name: postgres
hostname: postgres
platform: linux/amd64
volumes:
- ./data/postgres:/var/lib/postgresql/data
environment:
- POSTGRES_USER=xxxxxx
- POSTGRES_PASSWORD =xxxxxxxx
- POSTGRES_DB =xxxxxx
networks:
- my_network
networks:
my_network:
driver: bridge
this is the client code of parchaa-ndhm to abha-services
@Module({
imports: [
ClientsModule.register([
{
name: 'ABHA-SERVICES',
transport: Transport.TCP,
options: {
host:'abha-services',
port: 8081
}
}
])
],
controllers: [RegistrationMobileController],
providers: [RegistrationMobileService]
})
export class RegistrationMobileModule {}
also here is my bootstrap class
async function bootstrap() {
const app = await NestFactory.createMicroservice<MicroserviceOptions>(
AbhaServicesModule,
{
transport: Transport.TCP,
options: {
host:'0.0.0.0',
port: 8081,
retryAttempts: 3,
retryDelay: 1000
}
},
)
await app.listen()
console.log('abha-services started')
}
bootstrap();
I had try mentioning host in clientModule and bootstrap function of abha-services