Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use /etc/hosts to map localhost:3000 to a specific domain?

For development purposes I would like to map 127.0.0.1:3000 (localhost on port 3000) to something like local.example.com. I want to do this because I am testing an application that incorporates Facebook's SDK (OAuth). It's real pain to have to login to Facebook and change the registered domain for my application each time I make development changes locally. So in my /etc/host file I have the following:

127.0.0.1   localhost
127.0.0.1:3000  local.example.com
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost

local.example.com <- 404 but localhost:3000 <- works

How can I correctly alias localhost:port to a domain?

like image 427
Nick Avatar asked Oct 23 '25 14:10

Nick


1 Answers

No.

The HOSTS file helps map hostnames to IP addresses; this has nothing to do with TCP ports.

like image 161
SLaks Avatar answered Oct 25 '25 16:10

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!