- Stack Overflow Public questions & answers
- Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
- Talent Build your employer brand
- Advertising Reach developers & technologists worldwide
- About the company

Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Postgresql connection with gorm dial error cannot assign requested address
I'm trying to use the new gorm v2 implementation with Postgresql (I use Docker for the Golang app and for Postgres). I tried to do it as shown in the gorm documentation .
That gave me the following error:
web_1 | 2020/09/19 19:25:57 /go/src/caiqueservice/main.go:36 failed to connect to host=/tmp user=admin database=caique : dial error (dial unix /tmp/.s.PGSQL.5432: connect: no such file or directory)
So since the documentation didn't specify host , but the error message set that to /tmp I set that value.
Doing so gives me the following error message:
web_1 | 2020/09/19 19:36:47 /go/src/caiqueservice/main.go:36 failed to connect to host=localhost user=admin database=caique : dial error (dial tcp [::1]:5432: connect: cannot assign requested address)
The postgres db is reachable by pgadmin. I don't know what to do next and help would be very much appreciated.

- 1 is pgadmin connecting to localhost:5432? – elemetrics Sep 19, 2020 at 21:56
- Yes, it is @elemetrics – NickTheTramp Sep 20, 2020 at 8:08
- for dev purpose, you can also use 172.17.0.1 as hostname (container -> host machine) – aquaman Apr 2, 2021 at 17:48
Inside a container, localhost refers to the container itself, not to the host machine. If you are using docker-compose, you should be able to connect to the postgres container (from the app container) using the postgres container name as the host name. If you are running both containers separately, you will need to connect them to the same docker network or link them.
Your Answer
Sign up or log in, post as a guest.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy
Not the answer you're looking for? Browse other questions tagged postgresql go go-gorm or ask your own question .
- The Overflow Blog
- How Intuit democratizes AI development across teams through reusability sponsored post
- The nature of simulating nature: A Q&A with IBM Quantum researcher Dr. Jamie...
- Featured on Meta
- We've added a "Necessary cookies only" option to the cookie consent popup
- Launching the CI/CD and R Collectives and community editing features for...
- The [amazon] tag is being burninated
- Temporary policy: ChatGPT is banned
- Staging Ground Beta 1 Recap, and Reviewers needed for Beta 2
Hot Network Questions
- What video game is Charlie playing in Poker Face S01E07?
- Latex Table Missing Border Lines
- Linear Algebra - Linear transformation question
- How to use Slater Type Orbitals as a basis functions in matrix method correctly?
- Does a summoned creature play immediately after being summoned by a ready action?
- Question on Step X of Rudin's proof of the Riesz Representation Theorem
- How to tell which packages are held back due to phased updates
- Disconnect between goals and daily tasks...Is it me, or the industry?
- Copyright issues when journal is defunct
- Is it possible to rotate a window 90 degrees if it has the same length and width?
- Is there a solution to add special characters from software and how to do it
- Identify those arcade games from a 1983 Brazilian music video
- Do new devs get fired if they can't solve a certain bug?
- Is it known that BQP is not contained within NP?
- Do roots of these polynomials approach the negative of the Euler-Mascheroni constant?
- Largest Binary Area
- Why did Ukraine abstain from the UNHRC vote on China?
- Can Martian regolith be easily melted with microwaves?
- OK to delete Windows.db file on PC?
- Using indicator constraint with two variables
- Can I tell police to wait and call a lawyer when served with a search warrant?
- What can a lawyer do if the client wants him to be acquitted of everything despite serious evidence?
- If you preorder a special airline meal (e.g. vegan) just to try it, does this inconvenience the caterers and staff?
- Trying to understand how to get this basic Fourier Series
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .
Go: net/http: cannot assign requested address
- What version of Go are you using ( go version )? 1.6.2 and tip
- What operating system and processor architecture are you using ( go env )?
- What did you do?
Run this benchmark:
With: go test -bench=. -benchmem -benchtime=10s
- What did you expect to see?
It should work.
- What did you see instead?
It takes a long time and crashes:
During the benchmark, the value displayed by watch "ss -a | wc -l" increases really quickly (around 30-40k).
Most helpful comment
http.Get keeps a cache of TCP connections, but when all are in use it opens another one. It also sets a limit on the number of idle connections to a given host; the default is 2. If your GOMAXPROCS is more than 2 the benchmark is going to be regularly discarding connections and opening new ones. Each closed connection will be in TIME_WAIT state for two minutes, tying up that connection.
Try adding this line to your benchmark:
All 9 comments
If I write the benchmark without concurrency:
It works (no crash).
And the value displayed by watch "ss -a | wc -l" is low and stable (around 700).
I suspect you are exceeding the number of local socket connections permitted by your OS.
You are probably right, but I can't explain why.
I've performed the test again, with differents GOMAXPROCS values, and I displayed the number of network connection:
Most connections are in the TIME-WAIT state.
Should I configure something on my system or fix my code?
The point of a parallel benchmark is to run as many iterations of the function, in parallel, as will complete in 1 second. The benchmark will keep ramping up the number of iterations until it finds the answer. On your system, it seems that the answer is: more than the system can handle.
I would suggest that you put a limit in your code on the number of simultaneous open connections.
I'm going to close this issue because at this point I don't see anything to be fixed in Go.
As far as I know, there are only 8 simultaneous HTTP requests in my code. My GOMAXPROCS value is 8 (default value) and RunParallel() runs GOMAXPROCS concurrent benchmarks by default.
Does net/http.Get() opens a new connection for each request?
It works! Your explanation makes sense. Thank you very much ! :+1:
ss -s should show high number of tcp connections with much of them in TIMEWAIT . Allow the kernel to recycle and reuse these connections if not your limit of sockets will be exhausted
Add these 2 lines to your sysctl.conf .
net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1
The sysctl way causes issues: dial tcp 127.0.0.1:5001: i/o timeout
The MaxIdleConnsPerHost helped.
Related issues

IT Dead Inside

Nov 9, 2019
Member-only
Docker Containers and localhost: Cannot Assign Requested Address
Look out for your use of ‘localhost’ when using docker and docker compose.
This one might not be obvious at first glance. I hope this helps someone out there who may run into this same issue.
I’ve got an ASP.NET Core website which connects to an API. The website uses a proxy class…
More from IT Dead Inside
IT is a cesspool, but its home
About Help Terms Privacy
Get the Medium app

Christopher Laine
Author, programmer, would-be philosopher. Author of Screens https://christopherlaine.net/screens
Text to speech
- No suggested jump to results
- Notifications
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't assign requested address #177
saxoned commented Aug 12, 2020 • edited
vlastahajek commented Aug 12, 2020
Sorry, something went wrong.
saxoned commented Aug 13, 2020 • edited
Vlastahajek commented aug 13, 2020, saxoned commented aug 13, 2020.
- 😄 1 reaction
bugfix4u commented Aug 14, 2020
Vlastahajek commented aug 14, 2020.
bugfix4u commented Aug 14, 2020 • edited
No branches or pull requests

How I fixed Python OSError: [Errno 99] Cannot assign requested address
When binding a socket, you see an error message like
In my case, the issue was that I was trying to bind the specific IP address 192.168.1.100 but the computer running the script did not have said IP address configured on any interface.
so I needed to change the bind IP address to either 0.0.0.0 to listen to ANY IP address or I needed to change 192.168.1.100 to the IP address of the host computer I am running the script on.
Docker container [Errno 99] Cannot assign requested address
Note that for Docker containers, either you need to run them in network_mode: host to use the host’s network systemd, or you need to bind to the container’s IP address. You can not bind to the host’s IP address from the contaienr unless using network_mode: host ! But you can forward the ports from the host, binding to a specific IP address.
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow
- 3D printing (44)
- Algorithms (6)
- Allgemein (85)
- Android (3)
- Arduino (1)
- Audio/Video (25)
- Bioinformatics (23)
- Calculators (28)
- cloud-init (1)
- CoreOS (16)
- Docker (124)
- Kubernetes (11)
- Portainer (3)
- Cryptography (9)
- Data science (11)
- Documentation (1)
- Economics (1)
- Compliance (8)
- Components (13)
- Arduino (73)
- ESP8266/ESP32 (133)
- FreeRTOS (12)
- MicroPython (15)
- PlatformIO (130)
- Raspberry Pi (44)
- Teensy (10)
- Home-Assistant (10)
- LinuxCNC (6)
- LumenPnP (1)
- Medical devices (4)
- Teardown (1)
- ImageMagick (2)
- InvenTree (11)
- Wordpress (28)
- Generators (4)
- Leaflet (1)
- OpenStreetMap (4)
- Geoinformatics (5)
- Hardware (6)
- Alpine Linux (30)
- systemd (16)
- Machine learning (2)
- Mathematics (10)
- FreePBX (13)
- MikroTik (47)
- OpenWRT (9)
- Synology (1)
- Tactical RMM (1)
- Headscale (15)
- OpenVPN (2)
- Wireguard (24)
- ZeroTier (9)
- Nextcloud (11)
- OpenCASCADE (33)
- Patents (1)
- Performance (4)
- Physics (7)
- GCC errors (39)
- Haskell (8)
- Angular (25)
- NodeJS (43)
- Octave (13)
- Cartopy (15)
- OpenPyXL (7)
- pandas (50)
- Paramiko (4)
- skyfield (6)
- Typescript (15)
- Subversion (2)
- Statistics (6)
- ElasticSearch (34)
- MongoDB (9)
- Jupyter (1)
- OpenCV (10)
- Pyppeteer (13)
- Traefik (16)
- Virtualization (15)
- TechOverflow (2)
- PowerShell (4)
Privacy Overview
Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
bind: cannot assign requested address
I've recently switch over to AWS from Rackspace and I'm setting up a simple geolocation server using freegeopip . While the following commands work perfectly on a new Rackspace serve (Ubuntu) I can't getting working on AWS (tried Red Hat and Ubuntu). Here is the code I've used to set it up:
As I've said this works perfecectly on my Rackspace instace but AWS gives me this error:
I've checked this port with netstat and there is nothing running on it. I have no idea why I'm getting this error. Any ideas?
- amazon-web-services
- geolocation

2 Answers 2
In many cases, binding to 0.0.0.0 is the best course of action unless you have a specific reason to bind only to a specific address.
But I assume that what you're doing isn't working, because you're trying to bind to the instance's public IP address, which you'll find (via ifconfig ) your IP stack isn't aware of.
AWS instances are only natively aware of their private IP address, which is what you need to bind to.
EC2 (classic and VPC) instance public addresses associates with instances are 1:1 NAT translated to the private address by the AWS network infrastructure.
- I am also facing same issue.I want to use public ip of openstack vm instead of private ip i.e. eth0 ip. – Vikram Ranabhatt Mar 27, 2016 at 11:50
- @Chris_vr this question is about AWS, where binding to the wildcard or private IP specifically is the correct (and only) option. Openstack, I have no idea, but if you only see the private IP bound to the stack, the answer is probably similar, and if so, then trying to bind a socket to the public IP is the wrong way to accomplish what you are trying to do. – Michael - sqlbot Mar 27, 2016 at 11:59
AWS runs network address translation between your instance and the internet. So, the AWS instance might be reachable by the IP address 08.08.08.0808, however the server is actually configured to use 88.88.88.88. What I need to do was bind to the internal IP of the server which I found with ifconfig.
Your Answer
Sign up or log in, post as a guest.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy
Not the answer you're looking for? Browse other questions tagged amazon-web-services rackspace geolocation or ask your own question .
- The Overflow Blog
- How Intuit democratizes AI development across teams through reusability sponsored post
- The nature of simulating nature: A Q&A with IBM Quantum researcher Dr. Jamie...
- Featured on Meta
- We've added a "Necessary cookies only" option to the cookie consent popup
Hot Network Questions
- Why do small African island nations perform better than African continental nations, considering democracy and human development?
- Minimising the environmental effects of my dyson brain
- Does Counterspell prevent from any further spells being cast on a given turn?
- Identify those arcade games from a 1983 Brazilian music video
- Can Martian regolith be easily melted with microwaves?
- Where does this (supposedly) Gibson quote come from?
- Do I need a thermal expansion tank if I already have a pressure tank?
- Why is there a voltage on my HDMI and coaxial cables?
- Do roots of these polynomials approach the negative of the Euler-Mascheroni constant?
- "After the incident", I started to be more careful not to trip over things. - the incident has nothing to do with me; can I use this this way?
- How did “obarray” get its name?
- Is it known that BQP is not contained within NP?
- Difficulties with estimation of epsilon-delta limit proof
- Bulk update symbol size units from mm to map units in rule-based symbology
- Tips for golfing in SVG
- Euler: “A baby on his lap, a cat on his back — that’s how he wrote his immortal works” (origin?)
- Counting Letters in a String
- Question on Step X of Rudin's proof of the Riesz Representation Theorem
- Linear regulator thermal information missing in datasheet
- AC Op-amp integrator with DC Gain Control in LTspice
- Why are Suriname, Belize, and Guinea-Bissau classified as "Small Island Developing States"?
- Who owns code in a GitHub organization?
- Did any DOS compatibility layers exist for any UNIX-like systems before DOS started to become outmoded?
- Batch split images vertically in half, sequentially numbering the output files
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .
- Skip to primary navigation
- Skip to main content
- Skip to primary sidebar
- Skip to footer navigation
The Geek Diary
pscp – ssh_init: Network error: Cannot assign requested address
The PuTTY suite includes two programs for copying your files securely between machines. PSCP is a noninteractive program much like scp, and PSFTP is an interactive program inspired by ftp. You can use pscp (secure copy) and psftp (secure FTP) at the Windows XP Command Prompt. To copy a file with pscp, use:
For example:
I was playing around with pscp and encounted with an error:
1. It looks like pscp is using port 0 by default and mentioning the port allowed copying the file.
2. So I tries to provide the port number on the command line with “-P” option:
If you are going to copy files from Linux “down” to your Windows system, you need a program that will run on Windows. The creator of PuTTY made PSCP.EXE for precisely that purpose: to implement scp for Windows.
You May Also Like
- PRODUCT ISSUES
- Open or view cases
Need more help?
- My Citrix account
- Citrix Cloud
- Citrix Cloud Government
- My support alerts
- Sign out Sign in
Customers who viewed this article also viewed
{{item.title}}, error:"cannot connect to server" "can't assign requested address", applicable products, symptoms or error, problem cause.
1: None ADC issue
Confirmed in client packets and NetScaler nstrace, there is no TCP connection founded for launch failed desktop session. Client did not try to establish any TCP connection for desktop launch failed scenario. Only successful ICA connection recorded and matched with customer’s test results.
2: Client DNS resolution failured from CDF trace in receiver.
A hostname is being given of HDX-dektop.server to connect to. The Client, however, is translating this to the ip address of 0.0.0.2. The Implication here is that this is a secured environment that has a proxy setting in place to redirect many undesired addresses to 0.0.0.2. CDF Log: 37525,0,2020/08/05 17:51:22:57588,11944,7864,-1,HPC_ICA_ENG,SslASock_Api.c,467,SslASock_Connect(),1,Information,"SSL Relay host name:HDX-dektop.server resolved to: 10.204.182.11"," " (working scenario) 130535,0,2020/08/05 17:51:33:46960,13344,13428,-1,HPC_ICA_ENG,SslASock_Api.c,467,SslASock_Connect(),1,Information,"SSL Relay host name: HDX-dektop.server resolved to: 0.0.0.2", "" (NOT working scenario)
{{feedbackPageLabel}} feedback
You rated this page as, featured products.
Failed to load featured products content, Please try again .
{{ getHeading('digitalWorkspaces') }}
- {{ item.title }}
{{ getHeading('networking') }}
Filebeat + Netflow error: "bind: cannot assign requested address"
Dear all, I config filebeat and netflow ( softflowd on pfsense ) but I got issue. Any solution for that? Thanks systemctl status filebeat -l ● filebeat.service - Filebeat sends log files to Logstash or directly to Elasticsearch. Loaded: loaded (/usr/lib/systemd/system/filebeat.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2020-04-09 21:11:22 +07; 14s ago Docs: https://www.elastic.co/products/beats/filebeat Main PID: 10233 (filebeat) CGroup: /system.slice/filebeat.service └─10233 /usr/share/filebeat/bin/filebeat -e -c /etc/filebeat/filebeat.yml -path.home /usr/share/filebeat -path.config /etc/filebeat -path.data /var/lib/filebeat -path.logs /var/log/filebeat
My filebeat.yml: # Wazuh - Filebeat configuration file filebeat.modules: - module: wazuh alerts: enabled: true archives: enabled: false
My netflow.yml: # Module: netflow # Docs: https://www.elastic.co/guide/en/beats/filebeat/7.5/filebeat-module-netflow.html
Please take a look at this post: Udp 127.0.0.1:2055: bind: address already in use in 7.6 netflow module
Hi, but I don't config the filebeat.inputs
I changed from 192.168.1.23 to 0.0.0.0
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
- Unanswered topics
- Active topics
- Board index
- GoAnywhere MFT
- Knowledge Center
ERROR Cannot assign requested address: JVM_Bind
Support_Philip
- ↳ Knowledge Center
- ↳ Community Forum
- GoAnywhere Director
- ↳ Example Projects
- GoAnywhere Services
- GoAnywhere OpenPGP Studio
- Delete cookies
- All times are UTC-05:00
Privacy | Terms
Copyright © Fortra, LLC and its group of companies. All trademarks and registered trademarks are the property of their respective owners.
1-800-949-4696 Privacy Policy | Cookie Policy | Impressum
ES系列:ES启动报错解决 cannot assign requested address:bind

查看ip、端口是否重复(尤其是复制过来的目录) 查看ip、端口是否正确?
“相关推荐”对你有帮助么?

请填写红包祝福语或标题

如果对您有帮助,欢迎打赏支持!

您的余额不足,请更换扫码支付或 充值

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。 2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。


IMAGES
VIDEO
COMMENTS
1 You're running out of ports. Since you're setting w.Header ().Set ("Connection", "close") each request is going to take a new connection entirely. If you don't want to use up ports, re-use the connections. In your client, you're closing entire connection pool, which also will use up more resources.
net/http: cannot assign requested address · Issue #16012 · golang/go ...
Add a comment 1 Answer Sorted by: 7 Inside a container, localhost refers to the container itself, not to the host machine. If you are using docker-compose, you should be able to connect to the postgres container (from the app container) using the postgres container name as the host name.
Go: net/http: cannot assign requested address Created on 8 Jun 2016 · 9 Comments · Source: golang/go What version of Go are you using ( go version )? 1.6.2 and tip What operating system and processor architecture are you using ( go env )?
When using 8 concurrent goroutines => everything is OK When using more goroutines => after around 15s, every request fails with err="dial tcp 127.0.0.1:3306: connect: cannot assign requested address". Around 35 000 requests have been successfully performed before the first failure. Sign up for free to join this conversation on GitHub .
Docker Containers and localhost: Cannot Assign Requested Address | by Christopher Laine | IT Dead Inside | Medium 500 Apologies, but something went wrong on our end. Refresh the page, check...
can't assign requested address · Issue #177 · influxdata/influxdb-client-go · GitHub. Closed. on Aug 11, 2020.
ssh -D 1080 [email protected] [email protected]'s password: bind: Cannot assign requested address (where 8.8.8.8 is really my server's IP and 'user' is my real username) I am logged into the remote side in this terminal-window. I can verify that the local port was unused prior to this command, and then used by an ssh process, after the command, via:
Docker container [Errno 99] Cannot assign requested address. Note that for Docker containers, either you need to run them in network_mode: host to use the host's network systemd, or you need to bind to the container's IP address. You can not bind to the host's IP address from the contaienr unless using network_mode: host! But you can ...
listen tcp <MY IP ADDRESS>:8080: bind: cannot assign requested address I've checked this port with netstat and there is nothing running on it. I have no idea why I'm getting this error. Any ideas? amazon-web-services rackspace geolocation Share Improve this question Follow edited Feb 9, 2015 at 15:27 Vasili Syrakis 4,495 3 22 30
Quote: Check the /etc/hosts file and make sure that the nodes all have a. single definition and you don't have lines like. 127.0.0.1 localhost normnode3. and that normnode3 has the same address both on the master and on the. node. You can try. ping normnode3. from the master and see what address comes back.
ssh_init: Network error: Cannot assign requested address 1. It looks like pscp is using port 0 by default and mentioning the port allowed copying the file. C:\temp>pscp myfie.txt [email protected]:/home/test/ ssh_init: Network error: Cannot assign requested address 2. So I tries to provide the port number on the command line with "-P" option:
2: Client DNS resolution failured from CDF trace in receiver. A hostname is being given of HDX-dektop.server to connect to. The Client, however, is translating this to the ip address of 0.0.0.2. The Implication here is that this is a secured environment that has a proxy setting in place to redirect many undesired addresses to 0.0.0.2.
Dear all, I config filebeat and netflow ( softflowd on pfsense ) but I got issue. Any solution for that? Thanks systemctl status filebeat -l filebeat.service - Filebeat sends log files to Logstash or directly to Ela…
One way you can resolve this issue is by checking the HOST table to see if you are pointing the localhost address to an IP other than the IP of the server GoAnywhere was installed on. This this can occur when the server is a cloned VM server & has a static IP. Additionally, confirm that the address/IP configured for GoAnywhere is valid. Philip Horn
that it cannot assign requested source address. Os is the burden onto clients should i keep the private docker container, app to another commonly applied to your solution for contributing an existing flutter developer, cannot assign requested address golang. The dry field is untouched. Data management
编程时候出现了socket绑定失败,返回值为-1。利用perror定位错位为cannot assign requested address。大致上是由于客户端频繁的连服务器,由于每次连接都在很短的时间内结束,导致很多的TIME_WAIT,以至于用光了可用的端口号,所以新的连接没办法绑定端口,即"Cannot assign requested address"。