Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL2 Apache2 vhost not working #4347

Closed
UdVi86 opened this issue Jul 28, 2019 · 11 comments
Closed

WSL2 Apache2 vhost not working #4347

UdVi86 opened this issue Jul 28, 2019 · 11 comments

Comments

@UdVi86
Copy link

UdVi86 commented Jul 28, 2019

Hello!

I installed apache2 in WSL2,
modified root directory in apache2.conf:

<Directory /home/udvi/Projects/>
...
</Directory>

I create a test.conf in /etc/apache2/sites-available folder. It contains:

ServerName test.tld
DocumentRoot /home/udvi/Projects/test

Add test.tld to /system32/drivers/etc/hosts

127.0.0.1 test.tld

But not loading site test.tld

I modified DocumentRoot to /home/udvi/Projects/html in 000-default.conf and localhost sometimes loads well and sometimes doesn't, but test.tld never loads.

The error is: ERR_CONNECTION_REFUSED

@ad-on-is
Copy link

ad-on-is commented Jul 28, 2019

Same here with nginx, running in a docker-container.
Running ping test.add.dnmc (which is my TLD for local development) gives me

add@ADISDELL $ ping test.add.dnmc
PING test.add.dnmc (192.168.1.100) 56(84) bytes of data.
64 bytes from ADISDELL (192.168.1.100): icmp_seq=1 ttl=127 time=0.282 ms
64 bytes from ADISDELL (192.168.1.100): icmp_seq=2 ttl=127 time=0.314 ms
64 bytes from ADISDELL (192.168.1.100): icmp_seq=3 ttl=127 time=0.315 ms
64 bytes from ADISDELL (192.168.1.100): icmp_seq=4 ttl=127 time=0.291 ms
64 bytes from ADISDELL (192.168.1.100): icmp_seq=5 ttl=127 time=0.274 ms

@Drakota
Copy link

Drakota commented Jul 29, 2019

I have the same issue, sometimes it loads forever and the second time it loads instantly.
I've managed to make a vhost work by adding this in the hosts file.

127.0.0.1 test.tld
::1 test.tld

But it is extremely unstable and can't be used like this at the moment.
Sometimes a request load infinitely so I have to spam the same request until one goes through.

Here's an example of the issue

@Drakota
Copy link

Drakota commented Aug 1, 2019

Seems to be related to #4340

@UdVi86
Copy link
Author

UdVi86 commented Aug 2, 2019

127.0.0.1 test.tld
::1 test.tld

Thanks, it works! :)

@craigloewen-msft
Copy link
Member

The ERR_CONNECTION_REFUSED message indicates to me that this has to do with what IP address the apache server is bound to. We have a bug fix coming in to make this work, and are tracking it over in issue #4353 . I'll close this issue out as a duplicate to that one since I believe they have the same root cause. Thanks for filing!

@douglascorrea
Copy link

127.0.0.1 test.tld
::1 test.tld

This didn't work for me, any other workaround?

@douglascorrea
Copy link

I realized that, if I put:

::1             test.tld localhost

instead of

::1             localhost test.tld

in the Windows hosts file, it works, I don't know if this is a normal behaviour for IPv6

@btassone
Copy link

btassone commented Jul 31, 2020

The comment above worked for me

@ledunguit
Copy link

I have the same issue, sometimes it loads forever and the second time it loads instantly.
I've managed to make a vhost work by adding this in the hosts file.

127.0.0.1 test.tld
::1 test.tld

But it is extremely unstable and can't be used like this at the moment.
Sometimes a request load infinitely so I have to spam the same request until one goes through.

Here's an example of the issue

image
It's work for me, thanks lot, you saved my time ♥

@nicktchernikov
Copy link

nicktchernikov commented Feb 22, 2021

I can confirm that I was able to access what I needed after adding the following to the hosts file:
127.0.0.1 <my_domain> ::1 <my_domain>
Using WSL2, Ubuntu 18.04, Apache 2, and Chrome

@abetoots
Copy link

abetoots commented Jun 2, 2021

Also worked for me but still encountered errors related to DNS. I tried flushing dns in windows host using ipconfig /flushdns and now it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants