React.js 未连接到 EC2 上的 (localhost) Ganache:ERR_CONNECTION_REFUSED 127.0.0.1:8545

时间:2021-05-19 19:13:35

标签: reactjs ganache

在 Ubuntu Server 20.04 上使用以下安装:

sudo apt-get update 
sudo apt-get install nodejs 
sudo apt install python2 
sudo apt install npm 
npm install ganache-cli 
npm install node-gyp@3.6.2 
npm install truffle@5.1.39 
sudo npm install create-react-app@3.3.1 -global 
npm install

我遇到了错误 无法加载资源:net::ERR_CONNECTION_REFUSED 127.0.0.1:8545/:1

我正在使用命令行界面运行 ganache:

enter image description here

我可以通过节点命令提示符测试连接

enter image description here 我能够验证与 ganache 私有区块链的连接 enter image description here

然后我在 React 中尝试 App.js

enter image description here

出现以下错误: enter image description here

我尝试了以下方法:

1.) Setting up a proxy under package.json   :    http://127.0.0.1:8545
2.) Trying http://0.0.0.0:8545
3.) Setting up a middleware proxy account as presented in the following solution: 
https://medium.com/bb-tutorials-and-thoughts/react-how-to-proxy-to-backend-server-5588a9e0347
"proxy": "http://127.0.0.1:8545"
4.) addressing cache related issues through  rm -r package-lock.json node_modules and npm install updating react.js to latest version 
5.) trying different port: 7545
6.) updating react to latest version on ubuntu

0 个答案:

没有答案