Virtual Host ERR_NAME_NOT_RESOLVED - apache

I'm trying to set up a VirtualHost for laravel in apache on XAMPP.
I can access through Firefox, but if I type www.laravel.dev on Chrome I get this error "ERR_NAME_NOT_RESOLVED". Then, I tried to set it as "www.laravel.local" but it doesn't work either.
I followed this answer Google Chrome virtual hosts not working with ERR_NAME_NOT_RESOLVED error after update and when I flush it keeps on saying:
www.laravel.local IPV4 error: -105 (ERR_NAME_NOT_RESOLVED) 2015-06-23
16:53:09.090 [Expired]
This is my httpd-vhosts.conf:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/laravel/public/"
ServerName laravel.local
ServerAlias www.laravel.local
</VirtualHost>
And the /etc/hosts
127.0.0.1 localhost
127.0.0.1 www.laravel.local
Thank you for your time.

Related

Virtual host will NOT work in MAMP but works on localhost:8888

Created a new Laravel project in htdocs in MAMP. Followed all the steps, added virtual hosts, changed conf file, etc/hosts, restarted mamp and my pc several times but I just can't get my virtual host to run.
however, when I am in the MAMP Dashboard I can navigate to my website -> website -> public and the default Laravel boilerplate page appears.
Has anyone had this issues with MAMP before? I gave up with XAMPP and Valet so it's my last chance here..
Specs
High Sierra 10.13.5 on 2015 MBP,
Composer version 1.6.5,
php 7.2.7
httpd.conf
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
httpd-vhosts
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "Applications/MAMP/htdocs/website/public"
ServerName website.dev
</VirtualHost>
etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
#255.255.255.255 broadcasthost
#::1 localhost
127.0.0.1 website.dev
website.dev is technically a public url, so the browser is looking for it on the internet I guess. I was trapped once in this dreadful situation. changing the name to something like website.local should solve your issue. It did for me.

Can't debug to fix virtual host issue on windows 10

I have problem when i try to setup virtual host on my windows 10 pc.
In my hosts file:
127.0.0.1 project.dev
In my httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#project.dev
DocumentRoot "path to project"
ServerName project.dev
ErrorLog "logs/project.dev-error.log"
CustomLog "logs/project.dev-error-access.log" common
<Directory path to project>
Require all granted
Allowoverride All
</Directory>
</VirtualHost>
httpd.exe run without error.
I try to run:
localhost
It works but when i try to run:
project.dev
in the browser, it does not work.
This site can’t be reached
project.dev refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
I have tried to solve this issue for hours but i can't.
Windows firewall logs, System logs, Applications logs, Apache logs don't show me any infos to help me.
Could anyone help me debug this issue?
Thanks!
------------UPDATE--------
Today, i updated php and apache to newer version
https://windows.php.net/downloads/releases/php-7.2.6-Win32-VC15-x64.zip
https://www.apachehaus.com/downloads/httpd-2.4.33-o110h-x64-vc14-r2.zip
and tried to run project.dev with simple vhost:
<VirtualHost *:80>
DocumentRoot "C:/Users/0x1111/workspace"
ServerName project.dev
#ServerName www.example.com:80
</VirtualHost>
Chrome shows https error:
Your connection is not private
Attackers might be trying to steal your information from project.dev (for example, passwords, messages, or credit cards). Learn more
NET::ERR_CERT_AUTHORITY_INVALID
Running localhost it works normal.
----UPDATE -----
when i use nslookup localhost:
Server: resolver1-fs.opendns.com
Address: 208.67.222.123
Non-authoritative answer:
Name: localhost
Addresses: ::1
127.0.0.1
But when i nslookup project.dev:
Server: resolver1-fs.opendns.com
Address: 208.67.222.123
*** resolver1-fs.opendns.com can't find project.dev: Non-existent domain

Virtual Hosts Not Working under MAMP

I apologize for asking a question that's be asked before, but most of those questions have not been answered, and what few answers there are have not worked for me.
I am using Dreamweaver to build and manage my sites. Until now I have been successfully testing the sites on my remote host. But I want to add a database that I can test locally, so I am trying to use MAMP to create a virtual web server on my Mac (El Capitan, 10.11.5). Following standard instructions, after installing MAMP, I have edited the following files in my /private/etc folder as follows (showing only the changes):
etc/hosts
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
#127.0.0.1 fenixnest.pub.net
#127.0.0.1 fenixnest.dev.net
#127.0.0.1 fenixnest.tst.net
etc/apache2/httpd.conf
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
etc/apache2/httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/_FenixNest/"
ServerName fenixnest.pub.net
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/_FenixDev/"
ServerName fenixnest.dev.net
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/_FenixTest/"
ServerName fenixnest.tst.net
</VirtualHost>
Here are the results in my browsers (Safari and Chrome):
When I enter "localhost" I get the appropriate "It Works" page.
When I enter "localhost/fenixnest.dev.net", I get "The requested URL /fenixnest.dev.net was not found on this server." (The same for the "tst" and "pub" sites.)
When I enter "localhost/_FenixDev" (the name of the site root folder), I get "The requested URL /_FenixDev was not found on this server."
When I enter "fenixnest.dev.net", I get "This site can't be reached. fenixnest.tst.net’s server DNS address could not be found."
I have experimented with including "localhost/" as the prefix to the ServerName in both etc/hosts and etc/apache2/httpd-vhosts.conf. I have also tried commenting out the localhost block in etc/apache2/httpd-vhosts.conf (as suggested in one similar question). Nothing I have tried so far works.
I really would like to get a working virtual host on my Mac. Can anyone tell me what I'm doing wrong?

Google Chrome virtual hosts not working with ERR_NAME_NOT_RESOLVED error after update

I started getting this error for all my local virtual hosts on apache in the morning when I updated my Chrome to the latest version on ubuntu.
While all of them work on other browsers chrome started misbehaving with ERR_NAME_NOT_RESOLVED error.
Screen shot for the error
Got it fixed like this:
Clear up the Chrome's DNS cache by typing this in the Chrome browser
chrome://net-internals/#dns
Screenshot -> Flushing Chrome DNS cache
You will see a button "Clear Host Cache". Press that DNS cache
will be flushed.
Keep this DNS window open. Now access the virtual host in the browser
for me it was http:/api.localhost. Once you do that you will see a
new entry in the DNS window. for me it was "localhost."
notice the period "." at the end of localhost that showed an error.
Last step is to simply add this entry as
127.0.0.1 localhost.
in the hosts file located at
for ubuntu : /etc/hosts
for windows : C:\Windows\System32\drivers\etc\hosts
Another solution could be to ditch the .localhost /.dev at the end of your local virtual host domain
This has to do with some new changes by google. ".dev" and ".local" comes under google's TLD (In the corner of the internet where people care about DNS, there is a bit of an uproar at Google's application for over a hundred new top-level domains, including .dev etc)
Use a domain name you own. Possibly using the full name like "localhost.dev.$yourdomain" could help here on the setup.
Here is how to fix xampp virtual hosts in chrome and firefox that are ending with .dev. who doesn't work anymore (in most versions of chrome, since .dev is real domain registered and reserved from google - [Dev domain ICANN]).
I had so much trouble, with getting virtual hosts working properly
on both firefox and chrome, but at the end i find out that the best solution
is to make two different hosts for each local domain. So i ended up with something like: Here is hosts file in (C:\Windows\System32\drivers\etc\hosts):
This is needed, becouse if you still want your localhost alive
127.0.0.1 localhost.
::1 localhost.
fe80::1%lo0 localhost.
This works fine in Firefox.
127.0.0.1 laravel.dev
::1 laravel.dev
fe80::1%lo0 laravel.dev
This works perfectly on Chrome.
127.0.0.1 laravel.localhost
::1 laravel.localhost
fe80::1%lo0 laravel.localhost
And here is my xampp httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "D:/xampp/htdocs/"
ServerName localhost
ServerAlias localhost
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#laravel
DocumentRoot "D:/xampp/htdocs/laravel/public/"
ServerName laravel.dev
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#laravel
DocumentRoot "D:/xampp/htdocs/laravel/public/"
ServerName laravel.localhost
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#testsite
DocumentRoot "D:/xampp/htdocs/testsite/"
ServerName testsite.dev
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#testsite
DocumentRoot "D:/xampp/htdocs/testsite/"
ServerName testsite.localhost
</VirtualHost>
I hope this helps for someone, because i lost a couple hours, finding out the best solution, and make the things work. :)
tags - virtual host doesn't work on chrome.
Another option is to replace in your file /etc/hosts any entry defined as your_domain.localhost with something like local.your_domain. But this would also require you to change the "ServerName" and "ServerAlias" value in your virtual hosts files.
For me is working this:
In hosts:
127.0.0.1 localhost.
::1 localhost.
fe80::1%lo0 localhost.
And In httpd.conf:
<VirtualHost localhost>
DocumentRoot "D:/Apache/htdocs/projects/some-project-root"
ServerName some-project.localhost
</VirtualHost>
Important is write to VirtualHost tag "localhost", "127.0.0.1" does not works in chrome.

Forwarding from subdomain to port not working

the problem:
I am running a Windows Vserver and on this server I'm running a standalone Grails app on port 8081, which means that when I open
localhost:8081 (local) or domain:8081
in the browser, I see the interface of the Grails app.
What I am looking for is a way to type
subdomain.domain
that forwards me to
domain:port
I have read that this can be done using a virtual host on Apache. I used the XAMPP Apache because I'm running XAMPP MySQL anyway.
I added this line to the WIndows host file:
127.0.0.1 subdomain.domain
and this part to apache/conf/extra/httpd-vhosts.conf:
<VirtualHost *:80>
ServerName http://localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>
<VirtualHost *:80>
ServerName http://subdomain.localhost
Redirect / http://localhost:8081
</VirtualHost>
What I expected:
when I open domain I see the xampp admin interface
when I open subdomain.domain I see the Grails app (as domain:port)
What happens:
no matter wheather I open domain oder subdomain.domain I'm always forwarded to domain:port
What am I doing wrong?
Regards
H
Solution (no idea where the technical difference is):
<VirtualHost Server-IP:80>
ServerName http://domain
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>
<VirtualHost Server-IP:80>
ServerName http://subdomain.domain
Redirect / http://domain:port
</VirtualHost>
I even didn't have to make any entries in the Windows host file. NameVirtualHost wasn't necessary either.