2

I've come here as a last resort, I have a Windows machine installed on it is Oracle VB with Debian 12 VM on it that I use to run an API on.

When I try to access the API on the Linux server using 10.0.2.15:8000 it works fine and the API responds as expected.

So I made a port forwarding on Oracle (I am using a NAT adapter) to forward from 127.0.0.1:2022 the Windows host to 10.0.2.15:8000 the API on the Linux server.

Then I tried to connect to the API from my Windows machine using 127.0.0.1:2022 but it didn't work it kept on loading but nothing appears.

Note:

  • I use the same concept (port forwarding) to connect from my Windows machine to the Linux server using SSH and it works perfectly so idk why this is happening
  • I start the API using uvicorn --host 0.0.0.0 app.main:app so it should listen to any IP
  • I've set the CORS origins to origins = ["*"] so it should allow any origin

Port Forwarding window

CORS

1 Answer 1

3

Ok... I've been trying to solve this problem for the past 4 days and it turned out that the problem was with the firewall on Linux.

If anyone faces the same problem, run these commands.

iptables -I INPUT -p tcp -m tcp --dport {port_number} -j ACCEPT


sudo ufw allow {port_number}


sudo firewall-cmd --add-port={port_number}/tcp --permanent

Replace {port_number} with the port you wanna use. Also remove the curly brackets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.