How can I expose my Vite project in WSL2? - vite

I'm using the --host tag that gives me the Ip address of my pc with the exposed port 5173, but when I try to connect from the same network with my phone, I get the CONNECTION_TIMED_OUT error.

Related

Cannot access to WSL2 port opened via IPv6 from Windows host

I have a node-server running at WSL2 Ubuntu-20.04.
netstat -tulpn in WSL shows the following ports:
The ports specified as 0.0.0.0:8080 can be accessed in both WSL and Windows via 127.0.0.1:8080 url
My issue is that the ports specified as :::3006 can be accessed via 127.0.0.1:3006 only inside WSL, but from Windows, it works only via the network URL like http://172.28.100.200:3006.
When I send the request to 127.0.0.1:3006 from Windows, there is no connection error, but the server inside WSL does not receive it while using the network address, it does.
How can I investigate this and make the Windows port at 127.0.0.1:3006 forward requests into the same port in WSL?
UPDATE:
So I solved this by adding a port proxy, but again, WSL network IP is needed for this to work:
Any chance to avoid using network IP?

connect ECONNREFUSED to WSL2 ubuntu-18.04

I'm runing my flask project use wsl2 interpreter, and runing my vue project in my windows local, now there is a problem, yhr frontend can not connect backend, like below
Proxy error: Could not proxy request /summary_statistics from localhost:9527 to http://172.28.32.1:9999/
172.28.32.1 is my wsl2 ip.
anyone can help?
I have solve the problem, the IP is wrong..., I got from powershell with command
ipconfig
but I got another ip address in wsl with command
ifconfig
the true ip address is the second.

NodeJS and React - LAN connection not working

Description
I have a Node server and React App running on my notebook Ubuntu 18.04.
Notebook ip is 10.0.0.101
I tried to connect my desktop to this server on the same network
Desktop ip is 10.0.0.100
Node is running on PORT=3333
React is running on PORT=3000
I can ping my notebook from my desktop but when I try to connect to node using Insomnia or to http://10.0.0.101:3000 from my desktop I cannot reach.
Errors
When try to connect to backend with Insomnia
Error: Couldn't connect to server
When try to connect to app on 10.0.0.101:3000
ERR_CONNECTION_TIMED_OUT
What I've done
I already changed the node listen and specified the port and the ip but it didn't work.
I tried to use my phone as router and connect from my phone to react on my notebook and also didn't work.
I've tried so many things since I can't remember them all.
I'm also creating a react-native app and when I try to connect to my mobile using Expo, it just works using tunnel, but cannot get data from the backend.
Please save me.
Thanks
After making many failed attempts, I realized that the problem was in my notebook.
I checked my firewall and it was disabled and still cannot get acess to my notebook on LAN. But finally I discovered what have to be done
Solution
You have to open the specific port for TCP traffic
Ubuntu:
sudo ufw allow <PORT-NUMBER>/tcp
or for Red Hat Enterprise
firewall-cmd --add-port <PORT-NUMER>/tcp
Reference: Examples of how to open firewall ports

My node.js app is running, but cannot access it through servers ip

I have an app that is running on host: http://localhost:1111, when I try to access it through my server ip as follow: xxx.xx.xxx.xx:1111 it is not showing anything. When I run my app on my local pc it is running perfectly good
I tried to open ports, ping the ip with the port

Angular 4 Failed to load resource: net::ERR_CONNECTION_REFUSED

I guess I will start at the start of my application.
I am making a full mean-stack application and I want it to run in docker. To use docker I am using a virtualbox with Ubuntu. When I run my docker-compose, everything is working on localhost:4200. Now I want to open my application on my host machine (Windows 7).
When I go to my application via (ip addres should be kept secret, right?) xxx.xxx.xx.xxx:4200/login the page looks fine, but I get these errors:
I am using Angular cli 1.4.1 with node 8.4.0
Why am I getting these errors and how do I fix them?
My docker-compose
Your server which is listening on port 4200 is listening on your xxx.xxx.xxx.xxx interface (not necessary to hide lan IP, but nevermind...).
Your angular application is running on your host system. the localhost is the localhost of your host system, not the guest. so you have two solutions:
changing your urls inside the angular application to point to xxx.xxx.xxx.xxx:4200 instead of localhost:4200.
Forwarding your 4200 port from your host to your guest system using virtual box :
shutdown guest.
select guest and click on settings
go to the network tab.
click on "advanced"
then select "ports redirections" and bind your host 127.0.0.1:4200 to your guest's 4200 port

Resources