I am getting this:
GET http://locaohost:3001/api/v1/restaurants/ net:: ERR_CONNECTION_REFUSED
when I load from another computer in the local network.
How can I overcome this issue? It only comes when I try to run the react app from the remote computer in the same network.
You should use the IP address instead of localhost like the following:
http://192.168.0.115:3001/api/v1/restaurants/
To find your IP address, in windows OS you should open CMD and run ipconfig command and in macOS, you should open Terminal and run ifconfig command
Related
My operating system is Linux.
I am going to connect Superset to PostgreSQL.
PostgreSQL port is open and its value is 5432.
PostgreSQL is also running and not closed.
Unfortunately, after a day of research on the Internet, I could not solve the problem and it gives the following error:
The port is closed.
Database port:
command: lsof -i TCP:5432
python3 13127 user 13u IPv4 279806 0t0 TCP localhost:40166->localhost:postgresql (ESTABLISHED)
python3 13127 user 14u IPv4 274261 0t0 TCP localhost:38814->localhost:postgresql (ESTABLISHED)
Please help me, I am a beginner, but I searched a lot and did not get any results.
Since you're running Superset in a docker container, you can't use 127.0.0.1 nor localhost, since they resolve to the container, not the host. For the host, use host.docker.internal
I had a similar problem using docker compose. Port is closed can be due to networking problem. Host.docker.internal doesn’t worked for me on Ubuntu 22. I would like to recommend to not follow official doc and use better approach with single docker image to start. Instead of running 5 containers by compose, run everything in one. Use official docker image, here image. Than modify docker file as follows to install custom db driver:
FROM apache/superset
USER root
RUN pip install mysqlclient
RUN pip install sqlalchemy-redshift
USER superset
Second step is to build new image based on docker file description. To avoid networking problems start both containers on same network (superset, your db) easier is to use host network. I used this on Google cloud example as follow:
docker run -d --network host --name superset supers
The same command to start container with your database. —network host. This solved my problems. More about in whole step to step tutorial: medium or here blog
From the configuration file, you set port 5432, but it does not mean that your pg service is available
I have a React app made using create-react-app. I've been running this app without any issues for a few months now but have recently ran into an issue with starting the app because it says the port is in use. Here is the error message: Something is already running on port 3000. I'm trying to run the app on a Windows 10 machine.
Everything I've tried so far is listed below:
Running netstat -an and checking the output. This shows nothing running on port 3000.
Running netstat -an | findstr "3000". This shows no output.
Running npx kill-port 3000. I still get the port in use error message after running this.
Changing port that the app is running on. It doesn't matter which port I choose, it always says the port is in use.
Checking the Listening Ports list in Resource Monitor shows nothing listening on port 3000
Restarting my PC
The only thing that works is running the app in a Ubuntu 20.04 VM... which seems to indicate there's something listening on port 3000 on my Windows machine. However, I'm not sure what else I can do to troubleshoot this issue. I'm looking for suggestions on what else I could try.
Edit
Here's the contents of my hosts file C:\Windows\System32\drivers\etc\hosts:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
# Added by Docker Desktop
192.168.2.115 host.docker.internal
192.168.2.115 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
You can change it like below and try again, I'm not sure try once:
FYI, C:\Windows\System32\drivers\etc\hosts
Change to,
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
Instead of below this:
127.0.0.1 kubernetes.docker.internal
I resolved the issue by restarting the WinNAT service. I found the solution in the answers here: Error: listen EACCES: permission denied 0.0.0.0:3001
These are the steps:
Start Command Prompt or PowerShell as Administrator
Stop WinNAT with this command: net stop winnat
Start WinNAT again with this command: net start winnat
I'm trying to run the most basic react app possible and run it locally. I have referred to the startup docs: https://reactjs.org/docs/create-a-new-react-app.html
I run the app using both npm start from the docs and yarn start as indicated in the terminal. The result in the terminal looks like this:
My app appears to be running, but the IP address looks wrong. When I copy and paste this into my browser's address bar or try localhost:3000, my page does not load.
Other solutions I tried after referencing other StackOverflow threads:
restarting my computer
changing the port to another port
deleting and rebuilding the node_modules folder with yarn
None of those worked. What can I do to fix this?
I ran the command unset HOST in the terminal just before starting up my app and this worked.
Also, several other threads have referenced this article: https://choy.medium.com/fixing-create-react-app-when-npm-fails-to-start-because-your-host-environment-variable-is-being-4c8a9fa0b461
To set your localhost in .bash_profile do the following in the terminal...
Open bash profile in nano
nano .bash_profile
type HOST="localhost" and save this file
back in the terminal, type
source .bash_profile
I am using the latest Docker version (17 CE) on a Mac OSX and I have spun up an instance of SQL Server using the following tutorial: https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-setup-docker
The server was set up successfully and I managed to connect to it from outside the container via an SQL command line utility.
The next step is that I want to be able to connect to this instance from another PC within the same local network by assigning a public IP to the instance.
I have looked through a number of tutorials and it seems that with docker 10 this functionality is now possible, so I am looking to do it the 'right' way rather than the hacky way (pre-docker 10). I have looked through a number of tutorials namely How to assign static public IP to docker container and Assign static IP to Docker container.
I was testing using the ubuntu image to stay true to the example, but it still didn't work. Although the image ran, whenever I tried to ping the assigned IP from the same computer docker is installed on, I was not receiving a request timeout. Also on Kitematic the only host under IP AND PORTS is localhost. The image is being assigned to the custom network (docker network prune while instance is running does not prune my custom network) but I can't seem to discover my instance from the outside.
Commands I am using are
$ docker network create --subnet=172.18.0.0/16 mynet123
$ docker run --net mynet123 --ip 172.18.0.22 -it ubuntu bash
$ ping 172.18.0.22
and for my sql server
$ docker network create --driver=bridge --subnet=192.168.0.0/24 --gateway=192.168.0.1 mynet
$ docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=MyPassword123<>' -p 1433:1433 --ip=192.168.0.10 --net=mynet microsoft/mssql-server-linux
$ ping 192.168.0.10
What am I missing?
Any help would be appreciated.
How do you test to see if your program is working and able to connect with server? I tried stackoverflow server's ip through port 40 and it fails after a min at connect().
test.exe 64.34.119.12 echo 40
Program arguments take a syntax: <Server IP> <Echo Word> [<Echo Port>]
Also, can you test without having to connect to internet?
You should be able to connect to your own echo server on 127.0.0.1:7 if it is running, or get a 'connection refused' (ECONN) if it isn't running. Either would show that your code is OK actually.
As for testing without having to connect to the internet...
I'd download netcat for windows.
NetCat download
Extract the tool, and run:
nc.exe -v -l -p [port]
If you do that, it opens up a "server" and you can connect to it using your application; just point the IP address to 127.0.0.1!