Change Localhost to ip with port - windows

I am trying to setup a development server in house. Our IP points to our live server but we have seperate servers set on different ports.
For example our testing server could be on:
external: 97.95.xxx.xxx:1234
internal: 192.168.0.100:1234
We can view the test server by entering either ip in our browsers. We want to change all our development computers to access that server by entering "testserver". We have logged in and edited
C:\Windows\System32\Drivers\etc\hosts
We have added the following line of code to the systems with no success.
97.95.xxx.xxx:1234 testserver
If we remove the port number it will connect to our live system. Is there another system we need to edit to use that port?

when you add the port, your hosts edit is simply wrong.
according to example your hosts entry must look like
97.95.xxx.xxx testserver
and accessing the testsystem would be f.e.
http://testserver:1234
or
telnet testserver 1234
whatever connectiontype / purpose your connection is.

It seems that you cannot set ports in the hosts-file,
but there seems to be a way to forward the port:
port-forwarding-in-windows
src: no ports with hosts serverfault

Related

how to set an ip range for a virtualhost in host file

I want to let another person on my LAN see my Virtual host. I took some steps and now he can see my localhost when he enters my IP as an URL in browser. he couldn't see my virtualhost (shop.test) yet. so I edited his host file. I added my IP(192.168.1.3) tab shop.test. now he is able to see my vhost too. but there is a problem. my IP is Dynamic and for some reasons it should be this way. how can I use a range IP for shop.test in host file? or is there any other way for the purpose?
and what is the meaning of ::1 localhost in host file?
::1 localhost in your HOSTS file is the equivalent of 127.0.0.1 localhost but for the IPV6 address range. It is the loopback address for IPV6 like 127.0.0.1 is.
Modern browser will likely as not attempt to use the IPV6 range by default is they can
The PC running WAMPServer should be configured to use a static IP Address. Obviously it should not move or as you see it makes it difficult for other users to find it.
See this site for instructions on how to configure your PC with a static IP Address

/etc/hosts file not redirecting to local application on mac

I've set up a redirect in the hosts file on my machine that basically points an auth domain to my local project in IIS (when run in Visual Studio for Mac) - however when I type the domain name into Chrome (for example), I get a message saying this site cannot be reached.
The local URL I want this to point to is: http://localhost:44380/ - the live URL I can't reveal for security but lets say for the sake of this example that it's: auth.site.com (the actual URL I'm using is valid and it does load in Chrome)
Here's my hosts file from terminal as it's currently set up:
##
# 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 auth.site.com
I'm very familiar with windows and how the hosts file works, so from what I know there this would work in windows (I think anyways), is there something I'm missing here because obviously something isn't right?
I would first check where the problem is exactly. I think of the following possible issues:
Hosts file not properly working: Try running ping auth.site.com in a terminal. If you see responses from 127.0.0.1 this should work.
Is access to the port possible, open http://localhost:44380 in your browser. If you see your page, this should work.
Combine the two parts: open http://auth.site.com:44380 in your browser. If this does not work, maybe there are security features from the original page you visited before preventing access (like forcing SSL or a pinned certificate).
Try another browser or curl auth.site.com:44380 in a terminal.
If you are not happy with the given ports, you can do a port forwarding. Changing ports is not possible in the hosts file, because the hosts file is only for domain name lookup and this has nothing to do with the ports.
The listening address on the local instance would be http://auth.site.com:44380/

Can't access 127.0.0.1

I can't figure out when this started to happen, but the result is - 127.0.0.1 is not working on any port from anywhere (for example, browser says Unable to connect). Here are the results of my research:
localhost, COMPUTER_NAME and actual IP address all work fine
there is nothing special in my hosts file
ping to 127.0.0.1 and tracert do work fine
all the programs that have 127.0.0.1 hardcoded are not working (this point makes me disappointed the most, because I can't do anything in this case )
What else can I do to identify the source of problem and fix it?
UPDATE: as soon as Redis does work on 127.0.0.1 and both IIS and AzureStorageEmulator don't work I assume this is HTTP only issue.
Just one command did the work
netsh http add iplisten 127.0.0.1
If it's a DNS problem, you could try:
ipconfig /flushdns
ipconfig /registerdns
If this doesn't fix it, you could try editing the hosts file located here:
C:\Windows\System32\drivers\etc\hosts
And ensure that this line (and no other line referencing localhost) is in there:
127.0.0.1 localhost
In windows first check under services if world wide web publishing services is running. If not start it.
If you cannot find it switch on IIS features of windows: In 7,8,10
it is under control panel , "turn windows features on or off".
Internet Information Services
World Wide web services and
Internet information Services Hostable Core are required.
Not sure if there is another way to get it going on windows, but this worked for me for all browsers.
You might need to add localhost or http:/127.0.0.1 to the trusted websites also under IE settings.
I had a similar issue. Check your listen port.
A mistake I made ealier was
app.listen(() => console.log(APP_NAME} is listening on port ${PORT}`))
Make sure you include the port as shown below
app.listen(PORT, () =>{
console.log(`${APP_NAME} is listening on port ${PORT}`)
})
This answer may seem overly obvious, but in most cases it is sufficient to simply remove the "localhost" entry in the "Host Name" field:
In the end for us, it was IE11 that was blocking for 127.0.0.1 - after adding it to the exceptions list, it loaded the page.

java socket server hosting

I am creating an android client app connected to a Java server using sockets. At the moment I am working both on my pc. How can I upload my Java server to an online server so I can set my app to friends and test it?
I used OpenShift but could figure our how and if I can use it for what I want.
Also I looked at Amazon ec2, but they need credit card information, something that I would prefer not sharing for this.
Is there any way I can do this for free?
Thanks
Make sure you have a computer able to connect to the internet, and that can run 24/7. Then run your server on that computer, assume you run it on port 8080. Make sure that your host computer's IP address is it to static, otherwise DHCP will give it a different IP every time it connects to the router.
To allow your friends to connect, unless if they're on the same LAN as your host, you will need to port forward port 80 -> ComputerIP:8080 on your router. Once that's done, you will need to retrieve your router's global IPv4 address from it's configuration page and then send that to your friends.
If they're on the same LAN as your host, then you can just give them the IP address of your host computer.
If you port forwarded your server and you would like to get a host name, like stackoverflow.com, you're going to need to buy that from whoever owns the host name you would like to use. I don't know many details about how to update the DNS servers though.
If your server is local and you would like a host name, then just go onto your router configurations page and tell it to automatically assign each computer the default gateway as the primary DNS and then add a mapping in the router's DNS settings to map the host name to your computer's local IPv4 address. Note that not all routers support this feature.
Edit: You'll also need a good bandwidth to support multiple simultaneous connections.

Local URL IP redirect via port

I do a lot of custom web development and I am looking for a solution to a problem with testing.
I have a local development server that I run sandboxed environments on. When I need to test something I sometimes will edit my host file to make the domain point at my local IP
In my host file I would have.
127.0.0.1 mydomainname.com
What I would rather be able to setup is if I added a port to a URL:
mydomainname.com:7777
That would then redirect to my local IP
Something like this
127.0.0.1 *:7777
Is this a pipe dream or doable in someway?
You can use Firefox Extension Server Switcher
This firefox extension is a tool for web developers and allows switching between sites on your development and live servers; it helps you to see difference immediately.
It's more easy in use than host file.

Resources