Relative Content

Tag Archive for dockerapinetworkingcentoscontainers

Getting Network Error when calling rest api in container in the same docker network

I’m using a Centos 9 host in Digital Ocean, and have installed docker with 2 containers: 1) “swmpui” – a React node app with nginx reverse proxy with port map 8080:8080, and 2) “swmpapi” – a django python app with gunicorn gateway, port map 8000:8000. The api has a single post endpoint “/” that returns json. I call the api with axios, url “http://swmpapi:8000”, where I use the container name per docker docs. Both containers run in a bridge network “swmpnet” that I created. What I get from axios is message=”Network Error”, name=”Axios Error”, code=”ERR_NETWORK” and my browser console also reports “POST http://swmpapi:8000/ net::ERR_NAME_NOT_RESOLVED”.