iT邦幫忙

0

<解決>localhost 拒絕連線。(ERR_CONNECTION_REFUSED)

近期參考了一位做google login php的做法
http://codingpassiveincome.com/login-with-google-account
https://ithelp.ithome.com.tw/upload/images/20210824/201339159FEtsjlXpG.png
我點擊用google登入有跳到選擇帳號的頁面
https://ithelp.ithome.com.tw/upload/images/20210824/20133915atrgyBaglX.jpg
但是點帳號後localhost 就拒絕連線了
https://ithelp.ithome.com.tw/upload/images/20210824/20133915D2cYqnMscN.png
不清楚問題出在哪裡
我其他php檔都能正常開啟
更新:發文後自行找到解決方法了

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
0
firecold
iT邦新手 1 級 ‧ 2021-08-25 10:40:31

應該是hosts檔案沒有資料
127.0.0.1 localhost

//window10 路徑
C:\Windows\System32\drivers\etc\hosts

//linux 路徑
linux 
/etc/hosts
0
混水摸魚
iT邦研究生 2 級 ‧ 2021-08-25 12:06:48

你申請時應該有請你填網址,該網址需要是實際能用的網址名稱不能是localhost

1

localhost與127.0.0.1是特殊的用法。
跟一般正常使用的IP是不同的。

A機RUN 127.0.0.1 指向的是A機
B機RUN 127.0.0.1 指向的是B機

而一般正常IP指定的,如A機 123.123.123.123

A機RUN 123.123.123.123 指向A機
B機RUN 123.123.123.123 指向A機

所以,你要求GOOGLE對應localhost也就是127.0.0.1。
它會跑GOOGLE的機器,而不是你的機器。當然不給你連了。

我要發表回答

立即登入回答