Port problems to access a service inside a container

guys. I’m posting for a friend. He asked my help and we couldn’t find out what’s going on.

My situation is: my application works perfectly on Ubuntu 18.04 when it’s not inside a container, but the customer required the use of containers so I created a Dockerfile so it could be started by a Docker container.
Here’s the contente of my Dockerfile

FROM node:8.9.4

ENV HOME=/home/backend

RUN apt-get update
RUN apt-get install -y build-essential libssl-dev
RUN apt-get install -y npm

COPY . $HOME/

WORKDIR $HOME/

RUN npm rebuild node-sass
RUN npm install --global babel-cli


USER root

EXPOSE 6543

CMD ["babel-node", "index.js"]

After building the image, I execute the following Docker run command:
sudo docker run –name backend-api -p 6543:6543 -d backend/backendapi1.0

Taking a look at the log output, I can conclude that the application Works properly:
log output

I’ve created a rule in my nginx to redirect from port 90 to 6543 (before using containers it used to work)

server {
        listen 90;
        listen [::]:90;
        access_log /var/log/nginx/reverse-access.log;
        error_log /var/log/nginx/reverse-error.log;
        location / {
                proxy_pass http://localhost:6543;
           }
}

P.S.: i’ve tried to change from localhost to the container’s IP and it doesn’t work as well.
The fun fact is that when i try na internal telnet on 6543 it accepts the connection and closes it immediately.

telnet test

P.S.: all ports are open on the firewall.
The application Works normally outside the container (using port 6543 and redirecting in nginx)

I’d appreciate if someone could help us to find out the reason why it’s happening. We don’t have much experience creating containers.
Thanks a lot!

Source: StackOverflow